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

tanyaleblanc

Board Regular
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"
 

tanyaleblanc

Board Regular
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]
 

Fluff

MrExcel MVP, Moderator
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"
 

tanyaleblanc

Board Regular
It's still not working, its still pasting the date in all columns not just AJ
 

tanyaleblanc

Board Regular
All columns from G to AJ have the date in each cell down to the last cell using column G as my anchor.
 

Fluff

MrExcel MVP, Moderator
The code in post#4 does not do that for me. Do you have any merged cells on the sheet?
 

Some videos you may like

This Week's Hot Topics

  • Get External Data (long shot question!)
    This is likely a long shot but I am wondering if it is at all possible for Excel to somehow 'change' the contents of a URL that is being linked to...
  • Importing multiple excel files into one spreadsheet
    Hi, I'm trying to import multiple excel files (with the same format into a single spreadsheet) so that each day's file is listed underneath the...
  • Cell Formatting
    Good Morning, I need to format a few different cells in the following manners: A1 has to always add a colon (:) after whatever is typed in by a...
  • How to copy multiple rows using If
    Hi all, I'm very new to VBA and have written this simple code to copy certain cells if a certain cell within that row contains any data. I need...
  • Workbook_Change stopped working !
    I am working on an app to speed up & automate processing of Credit Cards statements. After data is input from a CSV file, it is presented to the...
  • VBA If statement
    Dear All, I have two dates, where I'd like a message box to pop, if the dates are between this criteria. [CODE] sDate1 = #10/1/2019#...
Top