VBA Search and copy (2 Workbooks involved)

longstick

New Member
Joined
Nov 19, 2011
Messages
42
I am looking to automate some updating that I do.

I will try my best to explain.

Book1:
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Serial#[/TD]
[TD]Cycle Count[/TD]
[TD]Date[/TD]
[TD]Complete[/TD]
[/TR]
[TR]
[TD]A4646366[/TD]
[TD]525200[/TD]
[TD]06/06/13[/TD]
[TD]Done[/TD]
[/TR]
[TR]
[TD]D2352352[/TD]
[TD]235500[/TD]
[TD]07/06/13[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]GC1223[/TD]
[TD]667200[/TD]
[TD]08/06/13[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]


Book2:
[TABLE="class: grid, width: 750"]
<tbody>[TR]
[TD]Serial #[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]Life Cycle Count[/TD]
[TD]Last Updated[/TD]
[/TR]
[TR]
[TD]F523523[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]1000000[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]G235252[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]2000000[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]D2352352[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]50000[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]A4646366[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]500000[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]GC1223[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]250000[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]


1. Search down the "Complete" column (Column D) to find the next empty cell (Row 3).
2. Check to see if the cell to the left has data. (is there new data that needs to be updated?).
3. Search the serial number from "Book1". Find it in "Book2".
4. Add the Cycle count of the serial number in "Book1" to the Life Cycle count in "Book2"
5. Update the "Last Update" in "Book2" with the date in "Book1"
6. If successful then place "Done" in blank cell found in step 1. If unsuccessful (example: Serial number not found in step 3) then place "Updating Error" in the cell.
6. Repeat until there is no more data in "Column C"


I hope I've explained what I would like.

Could you also place 'notes in the macro explaining what they lines do. I'm trying my best to learn.

Thank you,
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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