Hi All,
I'm using this code from another thread, but I want it to copy data down a row instead over a column. I tried this code, but it didn't work! Could you help me fix it?
Should be easy for you Excel programming experts!Private Sub Worksheet_Change(ByVal Target As Range) Dim LC As Long LC = Cells(1, Rows.Count).End(xlToDown).Row If Not Intersect(Target, Range("A2:J2")) Is Nothing Then Application.EnableEvents = False Range("A2:J2").Copy Cells(1, LC + 1) Application.EnableEvents = True End If End Sub
Thanks in advance!
Like so:
Private Sub Worksheet_Change(ByVal Target As Range) Dim LR As Long LR = Cells(Rows.Count, 1).End(xlToDown).Row If Not Intersect(Target, Range("A2:J2")) Is Nothing Then Application.EnableEvents = False Range("A2:J2").Copy Cells(LR + 1, 1) Application.EnableEvents = True End If End Sub
Last edited by JBeaucaire; 05-05-2011 at 11:47 AM.
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon below to give reputation feedback, it is appreciated.
Always put your code between code tags. [CODE] your code here [/CODE]
“None of us is as good as all of us” - Ray Kroc
“Actually, I *am* a rocket scientist.” - JB (little ones count!)
Hi JBeaucaire,
Thanks for the quick and helpful response. I'm getting an error with your code though.
This seems to be causing the problem...
LR = Cells(1, Rows.Count).End(xlToDown).Row
I've attached my macro-enabled Excel spreadsheet for you to take a look at.
Again, thank you so much for the help!
Cheers.
Try this instead.
LR = Cells(Rows.Count, 1).End(xlUp).Row
My bad, I didn't swap the params:
LR = Cells(Rows.Count, 1).End(xlToDown).Row
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon below to give reputation feedback, it is appreciated.
Always put your code between code tags. [CODE] your code here [/CODE]
“None of us is as good as all of us” - Ray Kroc
“Actually, I *am* a rocket scientist.” - JB (little ones count!)
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks