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
 

Some videos you may like

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
75,915
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
75,915
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)
 

Watch MrExcel Video

Forum statistics

Threads
1,113,917
Messages
5,545,024
Members
410,647
Latest member
bernardazar
Top