Help Writing a Macro

cal.bears

New Member
Joined
Sep 15, 2006
Messages
2
Hi,

i'm new to these forums and was wondering if anyone could help me write a macro for work. I have a workbook with two sheets. Each Sheet has a Folio Number in column A. I need to import data from sheet 2 (Columns B-H) into sheet 1 (Columns E-K) based on the Folio ID Number in Column A.

So basically in sheet 1 I need a program that looks up each rows folio Number, then looks up that number in Sheet 2, copies the relevant data in Sheet 2, then goes back to sheet 1 and pastes the data.

There are around 8,000 rows I need to populate in Sheet 1 through this method. I'm hoping there exists some way to program this into Excel via Macro/formulas.

-Alex
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,305
Office Version
  1. 365
Platform
  1. Windows
Alex

Do you really need code?

Couldn't you just use VLOOKUP?

For example in column E on sheet1,

=VLOOKUP(A1, Sheet2!$A$1:$B$8000, 2, 0)

In column F,

=VLOOKUP(A1, Sheet2!$A$1:$B$8000, 3, 0)

etc
 

cal.bears

New Member
Joined
Sep 15, 2006
Messages
2
Alex

Do you really need code?

Couldn't you just use VLOOKUP?

For example in column E on sheet1,

=VLOOKUP(A1, Sheet2!$A$1:$B$8000, 2, 0)

In column F,

=VLOOKUP(A1, Sheet2!$A$1:$B$8000, 3, 0)

etc

A variation of that formula works for Column E on sheet 1
=VLOOKUP(A2, Sheet2!$A$2:$B$8000, 2, 0). It returns the values I need.

For Column F it starts returning N/A values. I need it to always reference the Folio Number which is in Column A when it pulls up data.

So for Column F2. It should look to Column A2. Then go to Sheet 2. Find the same number in Column A and then copy the contents of that rows column.

Sheet 2 Columns B-H need to copy over to Sheet 1 Columns E-K.
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,305
Office Version
  1. 365
Platform
  1. Windows
Well all you need to do is anchor the column for the VLOOKUP value.

=VLOOKUP($A2, Sheet2!$A$2:$B$8000, 2, 0)
 

Forum statistics

Threads
1,143,637
Messages
5,719,962
Members
422,251
Latest member
bonebreaker100

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
Top