VBA - copy and past to next blank cell using another column as my anchor

tanyaleblanc

Board Regular
Joined
Mar 16, 2019
Messages
145
Hi, I'm trying to figure out a way to post a date of 05-15-2019 in column AJ and fill down to the last blank cell using column G as my anchor. When I use the code below, it not only puts 05-15-2019 in column AJ but all columns and this date changes each month, this month is 05-15-2019, but next month it's 06-15-2019 and so on. Is there a way to do that, currently I'm putting =NOW() in cell AJ1 and trying to copy that to the first blank cell in AJ and filling down to the last blank cell using G as my anchor, but this code is not working.

Any suggestions,


Code:
Windows("Rental Rec.xlsm").Activate    Sheets("Owned").Select
    lastrow = Cells(Rows.Count, "G").End(xlUp).Row
    Range("AJ1").Select
    Selection.Copy
    lrownew = Cells(Rows.Count, "AJ").End(xlUp).Row + 1
    Range("AJ" & Rows.Count).End(xlUp).Offset(1).Value = "05/15/2019"
    Range(Range("AJ" & Rows.Count).End(xlUp).Offset(1), Range("G" & Rows.Count).End(xlUp).Offset(, 2)).Value = "05/15/2019"
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
You need to change the offset from column G to 29
 
Upvote 0
Do you mean like this:

Code:
[COLOR=#333333]Windows("Rental Rec.xlsm").Activate    Sheets("Owned").Select[/COLOR]    lastrow = Cells(Rows.Count, "G").End(xlUp).Row
    Range("AJ1").Select
    Selection.Copy
    lrownew = Cells(Rows.Count, "AJ").End(xlUp).Row + 1
    Range("AJ" & Rows.Count).End(xlUp).Offset(29).Value = "05/15/2019" [COLOR=#333333]    Range(Range("AJ" & Rows.Count).End(xlUp).Offset(29), Range("G" & Rows.Count).End(xlUp).Offset(, 29)).Value = "05/15/2019"[/COLOR]
 
Upvote 0
Nope, just for column G
Code:
 Range(Range("AJ" & Rows.Count).End(xlUp).Offset(1), Range("G" & Rows.Count).End(xlUp).Offset(, 29)).Value = "05/15/2019"
 
Upvote 0
The code in post#4 does not do that for me. Do you have any merged cells on the sheet?
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,184
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top