-2

I want excel to print the date of next month on the next row in line. (There is a counter on the third row)

For example:

B28 = 01.07.2019 
C24 = 01.06.2019  
D16 = 01.02.2019 
E19 = 01.07.2019

Here is the screenshot: https://ibb.co/d0mW8GB

Dartagnan
  • 31
  • 6

1 Answers1

1

there are many missing parts from your question but i try to create a code to satisfy your needs. You could try:

Option Explicit

Sub makro3()

    Dim LastColumn As Long, LastRow As Long, Column As Long, Row As Long, Paid As Long

    'In your quetion there is no starting date so i use the current one

    With ThisWorkbook.Sheets("Sheet1")

        LastColumn = .Cells(3, .Columns.Count).End(xlToLeft).Column

        For Column = 2 To LastColumn

            Paid = .Cells(3, Column).Value

            For Row = 1 To Paid

                LastRow = .Cells(.Rows.Count, Column).End(xlUp).Row

                .Cells(LastRow + 1, Column).Value = DateAdd("m", Row, Date)

            Next Row

        Next Column

    End With

End Sub

Results:

enter image description here

Error 1004
  • 7,877
  • 3
  • 23
  • 46