Solved Autofill with dynamic origin range

August 16, 2019 at 00:48:41
Specs: Windows 10
Hi! I got this thing:

Sub AUTOFILLDATES()

Dim LASTROW As Long
Dim LASTROW2 As Long

With Sheets("Rate Plan Links")

LASTROW = Cells(rows.Count, 15).End(xlUp).Row
LASTROW2 = Cells(rows.Count, 1).End(xlUp).Row

Range("O2:P" & LASTROW).AUTOFILL Destination:=Range("O2:P" & LASTORW2)

End With
End Sub

I'm going crazy as I it doesn't let me select the entire rannge O2 to Pn.

All I need is these values(as en example)

08/15/2019 08/18/2019
08/19/2019 08/20/2019
08/21/2019 08/25/2019
08/26/2019 08/27/2019
08/28/2019 09/01/2019

to be copied n times until the last row in "O". Already checked that n of O is multiple of 5

Please somebody help!! Thanks a lot in advance!


See More: Autofill with dynamic origin range

Reply ↓  Report •

#1
August 16, 2019 at 04:51:17
First, a posting tip:

Please click on the How-To link at the end of this post and read the instructions on how to post VBA code in this forum so that it is easier for us to read. Then edit/repost your code so that it looks similar to the example found via that link.

Thanks!

As far as your issue, you have a typo in your Destination reference. Your Row variable for Column P is spelled incorrectly.

How To Post Data or Code ---> Click Here Before Posting Data or VBA Code

message edited by DerbyDad03


Reply ↓  Report •

#2
August 16, 2019 at 04:56:19
✔ Best Answer
BTW...

If you use Option Explicit, you'll be required to Dimension all of your variables. That would have caused an error telling you that you had a variable that was undefined and pointed you directly to the typo.

How To Post Data or Code ---> Click Here Before Posting Data or VBA Code

message edited by DerbyDad03


Reply ↓  Report •

#3
August 16, 2019 at 06:52:59
Thanks a lot DerbyDad03,ou made my day! I will be glad to share some of my macros here for future occaisons! :)

Reply ↓  Report •
Related Solutions


Ask Question