ضع هذا الكود في حدث الصفحة
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 2 Then Exit Sub
If Target.Value = Empty Then Range(Cells(Target.Row, 4), Cells(Target.Row, 24)) = Empty: Exit Sub
If Not Intersect(Target, [C2:C50]) Is Nothing Then
Range(Cells(Target.Row, 4), Cells(Target.Row, 24)) = Empty
Range(Cells(Target.Row, 4), Cells(Target.Row, 3 + Val(Target))) = Target.Offset(0, -1)
End If
End Sub