Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
'unhide all colums
If Target.Column = 17 And Target.Row = 9 Then
For i = 1 To 35
Columns(i).Hidden = False
Next
'hide columns not included in thr selected month
d = Format(DateSerial(Year(Range("Q9")), Month(Range("Q9")) + 1, 0), "dd")
For x = d + 2 To 32
Columns(x).Hidden = True
Cells(15, x) = ""
Next
Else
Exit Sub
End If
'renumber days
Z = 1
For x2 = 2 To 32
Cells(14, x2) = Z
Z = Z + 1
Next
'replace fridays days with Fr dependig on fromula (IF(WEEKDAY(Q9;1)=6;DAY(Q9);CHOOSE(WEEKDAY(Q9;1);DAY(Q9+5);DAY(Q9+4);DAY(Q9+3);DAY(Q9+2);DAY(Q9+1);DAY(Q9+0);DAY(Q9+6))))
For x = 2 To 32
If Cells(14, x) = Cells(12, 15) Or Cells(14, x) = Cells(12, 16) Or Cells(14, x) = Cells(12, 17) Or Cells(14, x) = Cells(12, 18) Or Cells(14, x) = Cells(12, 19) Then
Cells(14, x) = "fr"
End If
Next
End Sub
تفضل اخي المرفق بعد التعديل
لعله يكون المطلوب
husin1 (2).rar