
Sub Happy_New_Year()
Dim i As Integer, iNY As Integer
Dim x As Long, z As Long
iNY = 2015
Dim rngMese As Range
iNY = Year(Range("B8")) + 1
z = 8
i = IIf(Bisestile(iNY), 366, 365)
For x = 1 To 12 ' 12
i = 7 + 36 * (x - 1)
Debug.Print i
Set rngMese = Range("B" & z & ":B" & z + 30)
rngMese = "=DATE(" & iNY & "," & x & ",ROW()-" & i & ")"
rngMese = rngMese.Value
rngMese.Offset(0, -1).FormulaR1C1 = "=UPPER(LEFT(TEXT(RC[1],""GGGG""),1))"
rngMese.Offset(0, -1) = rngMese.Offset(0, -1).Value
z = z + 36
Set rngMese = Nothing
Next x
End Sub |
Sub Happy_New_Year()
Dim i As Integer, iNY As Integer
Dim x As Long, z As Long
iNY = 2015
Dim rngMese As Range
iNY = Year(Range("B8")) + 1
z = 8
i = IIf(Bisestile(iNY), 366, 365)
For x = 1 To 12 ' 12
i = 7 + 36 * (x - 1)
Debug.Print i
Set rngMese = Range("B" & z & ":B" & z + 30)
rngMese = "=DATE(" & iNY & "," & x & ",ROW()-" & i & ")"
rngMese = rngMese.Value
rngMese.Offset(0, -1).FormulaR1C1 = "=UPPER(LEFT(TEXT(RC[1],""GGGG""),1))"
rngMese.Offset(0, -1) = rngMese.Offset(0, -1).Value
z = z + 36
Set rngMese = Nothing
Next x
End Sub
Public Function Bisestile(Anno As Integer) As Boolean
Bisestile = ((Anno Mod 4) = 0 And (Anno Mod 100)) Or (Anno Mod 400) = 0
End Function
|
Sub Cambia_anno()
Dim g As Long, m As Long
Dim Nriga As Long
Dim anno_seriale As Long
Dim Giorno As String
anno_seriale = Year(Date)
For m = 1 To 12
Giorno = "1 " & m & " " & anno_seriale
Nriga = Application.Choose(m, 8, 44, 80, 116, 152, 188, 224, 260, 296, 332, 368, 404)
For g = 1 To Day(Application.EoMonth(CDate(Giorno), 0))
Giorno = g & " " & m & " " & anno_seriale
Cells(Nriga, "B") = CDate(Giorno)
Cells(Nriga, "A") = Application.Choose(Weekday(CDate(Giorno)), "D", "L", _
"M", "M", "G", "V", "S")
Cells(Nriga, "H") = CDate(Giorno)
Cells(Nriga, "G") = Application.Choose(Weekday(CDate(Giorno)), "D", "L", _
"M", "M", "G", "V", "S")
Nriga = Nriga + 1
If g = 27 Then
Cells(Nriga + 1, "A") = ""
Cells(Nriga + 1, "B") = ""
Cells(Nriga + 1, "H") = ""
Cells(Nriga + 1, "G") = ""
End If
Next g
Next m
End Sub
|
Sub cambiaanno2()
Dim j As Integer, m As Integer
Dim k As Long
Dim dStart As Date
Dim dData As Date
Dim nGiorni As Integer
nGiorni = (CDate("31/12/" & Year(Foglio14.Cells(8, 2).Value)) - CDate("01/01/" & Year(Foglio14.Cells(8, 2).Value)) + 1)
k = 7
dStart = Foglio14.Cells(8, 2).Value - 1
For j = 1 To nGiorni
k = k + 1
dData = dStart + j
Foglio14.Cells(k, 2).Value = dData
Foglio14.Cells(k, 1).Value = UCase(Left(VBA.WeekdayName(VBA.Weekday(dData, vbMonday), True), 1))
If dData = DateSerial(Year(dData), Month(dData) + 1, 0) Then
For m = k + 1 To (k + 31 - Day(dData))
Foglio14.Cells(m, 1).ClearContents
Foglio14.Cells(m, 2).ClearContents
Next m
k = k + (36 - Day(dData))
End If
Next
End Sub
|
Sub Cambia_anno()
Dim g As Long, m As Long
Dim Nriga As Long
Dim anno_seriale As Long
Dim Giorno As String
anno_seriale = Year(Date)
For m = 1 To 12
Giorno = "1 " & m & " " & anno_seriale
Nriga = Choose(m, 8, 44, 80, 116, 152, 188, 224, 260, 296, 332, 368, 404)
For g = 1 To Day(EOMonth(CDate(Giorno)))
Giorno = g & " " & m & " " & anno_seriale
Cells(Nriga, "B") = CDate(Giorno)
Cells(Nriga, "A") = Choose(Weekday(CDate(Giorno)), "D", "L", _
"M", "M", "G", "V", "S")
Cells(Nriga, "H") = CDate(Giorno)
Cells(Nriga, "G") = Choose(Weekday(CDate(Giorno)), "D", "L", _
"M", "M", "G", "V", "S")
Nriga = Nriga + 1
If g = 27 Then
Cells(Nriga + 1, "A") = ""
Cells(Nriga + 1, "B") = ""
Cells(Nriga + 1, "H") = ""
Cells(Nriga + 1, "G") = ""
End If
Next g
Next m
End Sub
Public Function EOMonth(DataMese As Date)
EOMonth = DataMese - Day(DataMese) + 45
EOMonth = EOMonth - Day(EOMonth)
End Function
|
Function EoMonth(ByVal MiaData As Date) As Date EoMonth = DateSerial(Year(MiaData), Month(MiaData) + 1, 0) End Function |
Private Sub Workbook_Open() On Error Resume Next ThisWorkbook.VBProject.References.AddFromFile "C:Program Files (x86)Microsoft OfficeOFFICE11LibreriaAnalysisATPVBAEN.XLA" On Error GoTo 0 'se seguono altre istruzioni End Sub |
