Public Sub SerieKalender() Application.ScreenUpdating = False Dim I As Date, II As Date, Ark As String StartAAr = InputBox("Indtast Startår") SlutAAr = InputBox("Indtast Slutår")
I = "01-01-" & StartAAr II = "31-12-" & SlutAAr For I = I To II Ark = Format(I, "mmm-yyyy", vbMonday, vbFirstFourDays) If Not (SheetExists(Ark)) Then 'laver ny Worksheets.Add.Move after:=Worksheets(Worksheets.Count) ActiveSheet.Name = Ark Worksheets(Ark).Cells(1, 1) = "Dag" Worksheets(Ark).Cells(1, 1) = "Dato" Else Worksheets(Ark).Cells(Day(I) + 1, 1) = Format(I, "dddd", vbMonday, vbFirstFourDays) Worksheets(Ark).Cells(Day(I) + 1, 2) = I End If Next
Application.ScreenUpdating = True End Sub Function SheetExists(IBox As String) As Boolean ' returnerer TRUE dersom arket finnes i den aktive arbeidsboken SheetExists = False On Error GoTo NoSuchSheet If Len(Sheets(IBox).Name) > 0 Then SheetExists = True Exit Function End If NoSuchSheet: End Function
ublic Sub SerieKalender() Application.ScreenUpdating = False Dim I As Date, II As Date, Ark As String StartAAr = InputBox("Indtast Startår") SlutAAr = InputBox("Indtast Slutår")
I = "01-01-" & StartAAr II = "31-12-" & SlutAAr For I = I To II Ark = Format(I, "mmm-yyyy", vbMonday, vbFirstFourDays) If Not (SheetExists(Ark)) Then 'laver ny Worksheets.Add.Move after:=Worksheets(Worksheets.Count) ActiveSheet.Name = Ark Worksheets(Ark).Cells(1, 1) = "Dag" Worksheets(Ark).Cells(1, 2) = "Dato" Worksheets(Ark).Cells(Day(I) + 1, 1) = Format(I, "dddd", vbMonday, vbFirstFourDays) Worksheets(Ark).Cells(Day(I) + 1, 2) = I Else Worksheets(Ark).Cells(Day(I) + 1, 1) = Format(I, "dddd", vbMonday, vbFirstFourDays) Worksheets(Ark).Cells(Day(I) + 1, 2) = I End If Next
Application.ScreenUpdating = True End Sub Function SheetExists(IBox As String) As Boolean ' returnerer TRUE dersom arket finnes i den aktive arbeidsboken SheetExists = False On Error GoTo NoSuchSheet If Len(Sheets(IBox).Name) > 0 Then SheetExists = True Exit Function End If NoSuchSheet: End Function
Public Sub SerieKalender() Application.ScreenUpdating = False Dim I As Date, II As Date, Ark As String StartAAr = InputBox("Indtast Startår") SlutAAr = InputBox("Indtast Slutår")
I = "01-01-" & StartAAr II = "31-12-" & SlutAAr For I = I To II Ark = Format(I, "mmm-yyyy", vbMonday, vbFirstFourDays) If Not (SheetExists(Ark)) Then 'laver ny Worksheets.Add.Move after:=Worksheets(Worksheets.Count) ActiveSheet.Name = Ark Worksheets(Ark).Cells(1, 1) = "Dag" Worksheets(Ark).Cells(1, 2) = "Dato" Worksheets(Ark).Cells(Day(I) + 1, 1) = Format(I, "dddd", vbMonday, vbFirstFourDays) Worksheets(Ark).Cells(Day(I) + 1, 2) = I Else Worksheets(Ark).Cells(Day(I) + 1, 1) = Format(I, "dddd", vbMonday, vbFirstFourDays) Worksheets(Ark).Cells(Day(I) + 1, 2) = I End If Next
Application.ScreenUpdating = True End Sub Function SheetExists(IBox As String) As Boolean ' returnerer TRUE dersom arket finnes i den aktive arbeidsboken SheetExists = False On Error GoTo NoSuchSheet If Len(Sheets(IBox).Name) > 0 Then SheetExists = True Exit Function End If NoSuchSheet: End Function
Luk nu på øverste X i højre hjørne, så er du tilbage på arket
Funktioner > Makro > Makroer, vælg SerieKalender og afspil
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.