I am new at this but want to use a macro to paste a row to the next available row on another worksheet. I do not understand code but was wondering if this could be done when recording a macro. Any help would be apreciated. I am working in excel 2007
I am new at this but want to use a macro to paste a row to the next available row on another worksheet. I do not understand code but was wondering if this could be done when recording a macro. Any help would be apreciated. I am working in excel 2007
Last edited by Srbills; 01-04-2012 at 11:25 AM.
If you record the macro, the next time you run it, it will paste the data in the exact same row as the previous run. You can do this through VBA coding.
for e.g.
This will copy row 2 (from A to G) from Sheet1 into sheet 2 in the next available row.Please Login or Register to view this content.
If I have helped, Don't forget to add to my reputation (click on the star below the post)
Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
Use code tags when posting your VBA code: [code] Your code here [/code]
Below is the macro as I have it. Could you show me what needs to be changed to make it paste to the next available row in the DATA worksheet. Everything works fine up until it pastes to the next available row in the DATA worksheet.
Sheets("Report").Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Sheets("COLLECTION").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("DATA").Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Last edited by Srbills; 01-03-2012 at 02:35 PM.
Your code seems incomplete in places. For example. It says -but its not showing what it is copying.Please Login or Register to view this content.
Also, you do not need to use .select in codes. You can directly copy like how i gave the example above.
One more thing, the code example i gave in post 2 will not work for paste special. In that case, you can alter the example asPlease Login or Register to view this content.
That works except that I would like it to end leaving the DATA worksheet in view instead of the COLLECTION worksheet. The code is below if you could tell me what to change.
Sheets("Report").Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Sheets("COLLECTION").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("DATA").Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteValuesAndNumberFormats
End Sub
Since you would like to continue with your style of coding, you just need to add a line at the end (before End Sub)
Please Login or Register to view this content.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks