• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Copy Date and paste to last cell in row with data

MikeT

New Member
Hi,
I am trying to copy a date in cell G2 and starting in cell G3 paste it down the rest of the cells in Column G and stop at the last row where there is data.
I am using the below code but it is not working. Appreciate your help. Thanks

Code:
Sub PasteDate()
'
' PasteDate Macro
'

'
    Range("G2").Select
    Selection.Copy
    Range("G3:G" & Lastrow).Select
    ActiveSheet.Paste
End Sub
 
Last edited by a moderator:

vletm

Excel Ninja
MikeT ... okay
You wrote: I am trying to copy a date in cell G2 and starting in cell G3 paste it down the rest of the cells in Column G and stop at the last row where there is data.
How Your code, which do not work well, try to solve/take care the last row? How do it know, what is it? Do You know?
 

MikeT

New Member
Hi, thanks for your help and time to reply back.
The short answer is no I don't know. I can make Lastrow work for a specific range of cells ie G3:G10 but cannot figure out how to tell the code to stop at the last row of the column where there is data in that row. I was able to figure out the last row function to autofill column C below but keep getting errors on everything I have been trying for the last 5 hours.

>>> use code - tags <<<
Code:
Sub AutofillDown()
'
' AutofillDown Macro
'

'
    Range("C2").Select
    Selection.AutoFill Destination:=Range("C2:C" & Range("E" & Rows.Count).End(xlUp).Row)
Range(Selection, Selection.End(xlDown)).Select

End Sub
 
Last edited by a moderator:

vletm

Excel Ninja
MikeT
Why did You change Your ... thread?
If something has taken ... five hours ... then You should take 10minutes break ... walk or something...

Next, You should find out - what do You mean about Your last row?
Based Your original writing ... I could be something like below.
Next ... do You copy or what? ... or something like below?
Code:
Sub Do_It()
    With ActiveSheet
        lastrow = .UsedRange.Rows(.UsedRange.Rows.Count).Row
'   next IF needs
        if lastrow > 2 then .Range("G3:G" & lastrow) = .Range("G2")
    End With
End Sub
 
Last edited:
Top