Copy, Find Row, Then Paste Between Worksheets

eririt

New Member
Joined
Jul 9, 2011
Messages
4
I collect orders through e-mailed Order Form Workbooks (file names will vary). When the order arrives, my macro unprotects the Order Form, unhides the Order Summary tab, copies the order data and activates the Order List tab in the Master Workbook, which is already open in the background and is where the macro is saved.

From here, I manually search for the Store ID # in Column A and paste the Order Data into that store's row. I'd like to automate this part of it by teaching the macro to reference the Store ID # in Cell A3 of the Order Form Workbook and then look for that ID # in the Master Workbook and paste the data.

This is my current code and attached workbooks for examples. Thank you!

Code:
[COLOR=#222222][FONT=Verdana]Sub CopyPaste()[/FONT][/COLOR]
ActiveWorkbook.Unprotect "NAN"   'Order Workbook will arrive password protected
Sheets("OrderData").Visible = True         'Sheet with order data is hidden
Sheets("OrderData").Activate

'This copies Order data to make it ready for pasting into the Master workbook.

Dim storeOrder As Range
Set storeOrder = Range(Cells(3, 2), Cells(3, 52))
storeOrder.Copy

ActiveWorkbook.Activate       'To switch from Order Form Workbook to Master Workbook

'MasterOrders Sheet contains Store ID # list in range A3:A250.
Sheets("MasterOrders").Activate

How to I continue by finding the Store ID # in column A and then paste StoreOrder in the matching row?
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Hi eririt,

Since you already know coding, I would suggest you to search internet for VBA Loops and you will find the solution. Thanks.

Regards,
DILIPandey
 
Upvote 0
copies the order data and activates the Order List tab in the Master Workbook, which is already open in the background and is where the macro is saved.

From here, I manually search for the Store ID # in Column A and paste the Order Data into that store's row. I'd like to automate this part of it by teaching the macro to reference the Store ID # in Cell A3 of the Order Form Workbook and then look for that ID # in the Master Workbook and paste the data.

Just want to make sure I'm getting this straight, your workbooks and sheets are:

Workbooks("Order Form").Sheets("OrderData")

and

Workbooks("Master").Sheets("MasterOrders")

Correct?
 
Upvote 0
Save back-ups of your workbooks, then try something like this:

Code:
Sub myCopyPaste()

Dim storeOrder As Range, storeID As Variant, storeRow As Long

ActiveWorkbook.Unprotect "NAN"

With Sheets("OrderData")
    .Visible = True
    storeID = .Range("A3").Value
    .Range(.Cells(3, 2), .Cells(3, 52)).Copy
End With

With Workbooks("Master").Sheets("MasterOrders")
    storeRow = .Range("A:A").Find(storeID).Row
        .Range("B" & storeRow).PasteSpecial
End With

End Sub
 
Last edited:
Upvote 0
Almost. The "Order Form" workbook actual file name will vary. This is the workbook that gets e-mailed back to me from 200+ different contacts. "OrderData" is the sheet name and will always have that name. ("Master").Sheets("MasterOrders") is going to be consistent as this is the file I own and compile all orders into.
 
Upvote 0
Almost. The "Order Form" workbook actual file name will vary. This is the workbook that gets e-mailed back to me from 200+ different contacts. "OrderData" is the sheet name and will always have that name. ("Master").Sheets("MasterOrders") is going to be consistent as this is the file I own and compile all orders into.

Ok, good. See if the code I posted works.
 
Upvote 0

Forum statistics

Threads
1,223,719
Messages
6,174,089
Members
452,542
Latest member
Bricklin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top