Help on using macro to filter out data

Worldmarket

New Member
Joined
Feb 21, 2011
Messages
2
I'll like somebody to help me out please. I have a sheet containing numbers in column A and names in column B. I have another sheet that is only containing numbers. I want to know if it is possible to use macro in looking up to the first sheet that has the numbers and the names so that i can match the names in the first sheet with their corresponding numbers in the second sheet.

e.g of my first sheet.


number name
111 michael
112 jessica
113 monica
114 camel
115 sentel
116 jupita
117 camer
118 zuma
119 hector
120 king
121 komn
122 zepra
123 jossy
124 hops
125 comt


e.g of my second sheet
number name
111
113
115
117
119
121
123
125
127
129
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
you don't really need a macro, use vlookup
Excel Workbook
AB
1NumberName
2111michael
3113monica
4115sentel
5117camer
6119hector
7121komn
8123jossy
9125comt
10127#N/A
11129#N/A
Sheet2
Excel 2003
Cell Formulas
RangeFormula
B2=VLOOKUP(A2,Sheet1!A:B,2,FALSE)
B3=VLOOKUP(A3,Sheet1!A:B,2,FALSE)
B4=VLOOKUP(A4,Sheet1!A:B,2,FALSE)
B5=VLOOKUP(A5,Sheet1!A:B,2,FALSE)
B6=VLOOKUP(A6,Sheet1!A:B,2,FALSE)
B7=VLOOKUP(A7,Sheet1!A:B,2,FALSE)
B8=VLOOKUP(A8,Sheet1!A:B,2,FALSE)
B9=VLOOKUP(A9,Sheet1!A:B,2,FALSE)
B10=VLOOKUP(A10,Sheet1!A:B,2,FALSE)
B11=VLOOKUP(A11,Sheet1!A:B,2,FALSE)
 
Upvote 0
Seems like VLookup or Match/Index would do the job without the need to use a macro.

Assuming they are called "Sheet1" and "Sheet2" and you're starting in A1 then in Sheet2!B2 input the following formula: =VLOOKUP(Sheet2!A1,Sheet1!A1:B20,2,FALSE) and then copy as far down as necessary.

Hope this helps
 
Upvote 0
I appreciate your help. But I am still having a problem. the data in sheet two numbers in sheet two were randomly selected out of many numbers and names in sheet one. I tried what you guys wrote but some were giving me wrong names.
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,750
Members
452,940
Latest member
rootytrip

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