![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Apr 2002
Posts: 1
|
i have a workbook with sheets for each day of the week. on each sheet the left hand column has a persons name and to the right each column is for different data that i have to take from another sheet.
i was wondering how to write a macro to search that other sheet for their name and then search for a columns data and paste it in the cell |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Mar 2002
Location: Boston, MA
Posts: 105
|
I just did this one the other day. I recommend runing a loop that uses the VLOOKUP function to find the data you need. With the VLOOKUP, you'll need a variable to represent the name. Then lookup the name in some huge range on the other sheet like A1:FF1000, and for the column use a MATCH method. Example below:
Name Num1 Num2 Num3 Green 3 4 5 Smith 1 2 3 Jackson 3 6 5 Jones 8 7 6 Dim Person as String Sub LocateLoop() Sheets("MasterSheet").Select Range("A2").Select Do Until NotIsEmpty(ActiveCell) Person = ActiveCell.Value ActiveCell.Offset(0,1).Formula = "=VLOOKUP(""" & Person & """,[SheetWithData]!A1:FF1000,MATCH(""Num2"",[SheetWithData]!A1:FF1,0),FALSE)" ActiveCell.Offset(1,0) Loop End Loop |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|