Solved Macro that copies info from one sheet to another

June 4, 2012 at 13:32:17
Specs: Windows 7
I currently have a "Work_Order_Form" for repairs that we fill in and print out. We don't store the info on the form. I copy and paste certain infromation from the form onto a second sheet. The second sheet, Repair_Database, is a list containing the info from the Work_order_forms that we've printed.

Now, I do have a macro that will copy information from the form onto the second sheet. The problem I have is when I run the macro the new information is replacing the info on the second sheet instead of adding it. I don't know what info I need to add to the macro to have it paste this info into a new row instead of replacing it.

I found a "copy block" macro online and have tried to edit it but can't get it to work.

Here is the code for the macro that I recorded:
Sub Macro1()
' Macro1 Macro
' Macro recorded 6/4/2012 by Andrea
End Sub

I really hope someone can help me. This is my first time writing a macro and I am not at all familiar with the terminology so the simpler the explanation the better. I hope some one can help!

See More: Macro that copies info from one sheet to another

June 4, 2012 at 13:47:02
✔ Best Answer
First, before posting any more code in this forum, please click on the blue line at the bottom of this post and read the instructions found via that link.

Second, rarely, if ever, do you have to Select an object in VBA to perform an operation on it.

The code you posted can be condensed as follows:

Sub CopyPaste()
  Sheets("Work_Order_Form").Range("A3:F3").Copy _
End Sub

Finally, the standard syntax to find the next empty row via VBA is as follows, assuming that there is data in Column A. If not, choose a column that will always have data in it.

nxtRow = Sheets("Repair_Database").Range("A" & Rows.Count).End(xlUp).Row + 1

Given that, your code might look like this:

Sub CopyPaste_v1()
 nxtRow = Sheets("Repair_Database").Range("A" & Rows.Count).End(xlUp).Row + 1
   Sheets("Work_Order_Form").Range("A3:F3").Copy _
     Destination:=Sheets("Repair_Database").Range("A" & nxtRow)
End Sub

Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.

Report •
Related Solutions

Ask Question