Compare a column in two sheets and copy and paste into one

nancy.darnell

New Member
Joined
Jul 19, 2007
Messages
6
I need help creating a macro to perform following:

I have two excel sheets One is called "upload_data" and the "query1".
I want to compare one column called "product_id" in both sheets. They are in different order in each sheets. After comparing and finding the right "product_id" in "query1" sheet. I want to copy the data from "Description" column in "query1" to paste into "upload_data" sheet "Description". Please let me know how to do this. thanks

Nancy
 

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).
Hi

Assuming product ID in col A, descriptin in Col D
In upload_data sheet description column you can insert the formula
=vlookup(A1, query!A1:D100,4,false) and drag it till the end of data

if you want a macro, Paste the following codes in the macro window ( alt F8)

Code:
x= worksheets("upload_data").cells(rows.count,1).end(xlUp).row
for a = 1 to x
cells(a,4) = application.worksheetfunction.vlookup(cells(a,1), worksheets("query1").range("A1:D100"),4,False)
next a
Run the macro
Ravi
 
Upvote 0

Forum statistics

Threads
1,214,424
Messages
6,119,404
Members
448,893
Latest member
AtariBaby

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