Guten Abend,
ich habe gerade diesen VBA-Code geschrieben (funktioniert). Könnte das jemand bitte beurteilen und sagen, was eleganter geht? Der Code soll weitere Datumsangaben hinzufügen. Ein Erstdatum steht in der Excel drin.
Danke & Viele Grüße
Bartosz
VBA
ich habe gerade diesen VBA-Code geschrieben (funktioniert). Könnte das jemand bitte beurteilen und sagen, was eleganter geht? Der Code soll weitere Datumsangaben hinzufügen. Ein Erstdatum steht in der Excel drin.
Danke & Viele Grüße
Bartosz
Quellcode
- Option Explicit
- Sub Add_Datumsangaben(n As Integer)
- Dim WB As Workbook
- Dim WS As Worksheet
- Set WB = ActiveWorkbook
- Set WS = Sheets("Gesamt")
- WB.Activate
- WS.Select
- Dim Last As Integer
- Last = WS.Cells(Rows.Count, 1).End(xlUp).Row + 1
- Dim End_ As Integer
- End_ = Last + n - 1
- Dim i As Integer
- Dim currentDate As Variant
- currentDate = WS.Cells(Last - 1, 1).Value
- For i = Last To End_
- currentDate = DateAdd("d", 1, currentDate)
- WS.Cells(i, 1).Value = currentDate
- WS.Cells.NumberFormat = "dd.mm.yyyy"
- Next i
- End Sub
- Sub Makro1()
- Add_Datumsangaben 5
- End Sub