
Sub CalendarioPer()
Dim Mese As Long, Anno As Long
Dim Giorno As Date
Dim i As Integer
Mese = Cells(3, 4)
Anno = Cells(3, 5)
Giorno = CDate("1" & "/" & Mese & "/" & Anno)
Range("C5:D35") = ""
Range("C5:D35").Interior.ColorIndex = xlNone
Cells(4, 4) = UCase(Format(Giorno, "mmmm"))
For i = 5 To 35
If Month(Giorno) <> Mese Then Exit For
Cells(i, 3) = Day(Giorno)
Cells(i, 4) = Application.Proper(Format(Giorno, "dddd"))
If Weekday(Giorno) = 7 Then Cells(i, 4).Interior.ColorIndex = 6
If Weekday(Giorno) = 1 Then Cells(i, 4).Interior.ColorIndex = 3
Giorno = Giorno + 1
Next i
End Sub |
'' codice utilizzato in foglio 1
Sub CalendarioPer()
Dim Mese As String, MeseNum As Integer, Anno As String
Dim Giorno As Date
Dim i As Integer
Mese = Cells(3, 4)
Anno = Cells(3, 5)
Application.EnableEvents = False
ActiveSheet.Unprotect
Giorno = CDate("1" & "/" & Converte(Mese) & "/" & Anno)
Range("C5:D35") = ""
Range("C5:D35").Interior.ColorIndex = xlNone
Range("C5:D35").Font.ColorIndex = xlAutomatic
MeseNum = Converte(Mese)
For i = 5 To 35
If Month(Giorno) <> MeseNum Then Exit For
Cells(i, 3) = Day(Giorno)
Cells(i, 4) = Application.Proper(Format(Giorno, "dddd"))
If Weekday(Giorno) = 7 Then Cells(i, 4).Interior.ColorIndex = 6
If Weekday(Giorno) = 1 Then Cells(i, 4).Interior.ColorIndex = 3
Giorno = Giorno + 1
Next i
ActiveSheet.Protect
Application.EnableEvents = True
End Sub
Function Converte(Stringa As String)
Dim Val_mese As Integer
Select Case UCase(Stringa)
Case "GENNAIO"
Val_mese = 1
Case "FEBBRAIO"
Val_mese = 2
Case "MARZO"
Val_mese = 3
Case "APRILE"
Val_mese = 4
Case "MAGGIO"
Val_mese = 5
Case "GIUGNO"
Val_mese = 6
Case "LUGLIO"
Val_mese = 7
Case "AGOSTO"
Val_mese = 8
Case "SETTEMBRE"
Val_mese = 9
Case "OTTOBRE"
Val_mese = 10
Case "NOVEMBRE"
Val_mese = 11
Case "DICEMBRE"
Val_mese = 12
Case Else
Val_mese = 1
End Select
Converte = Val_mese
End Function
|
Sub CalendarioPer()
Dim Mese As String, MeseNum As Integer, Anno As String
Dim Giorno As Date
Dim i As Integer
Mese = Cells(3, 4)
Anno = Cells(3, 5)
Application.EnableEvents = False
ActiveSheet.Unprotect
Giorno = CDate(1 & " " & Mese & " " & Anno)
Range("C5:D35") = ""
Range("C5:D35").Interior.ColorIndex = xlNone
Range("C5:D35").Font.ColorIndex = xlAutomatic
MeseNum = Month(Giorno)
For i = 5 To 35
If Month(Giorno) <> MeseNum Then Exit For
Cells(i, 3) = Day(Giorno)
Cells(i, 4) = Application.Proper(Format(Giorno, "dddd"))
If Weekday(Giorno) = 7 Then Cells(i, 4).Interior.ColorIndex = 6
If Weekday(Giorno) = 1 Then Cells(i, 4).Interior.ColorIndex = 3
Giorno = Giorno + 1
Next i
ActiveSheet.Protect
Application.EnableEvents = True
End Sub |
