Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I need to scan through a list of names and find there resource code in
a lookup table. The macro and the lookup table itself aren't in the actual file I'm processing. I've defined the lookup table in the workbook where the macro resides. The table looks like this: SMITH, JUDY MECH. ENGINEER IV DOE, JOHN ADMIN ASST I I created a workbook level name, "RES_CODE_LOOKUP", that refers to the lookup table. My first attempt at the macro: ------begin code--------- Sub LookupNames() Dim lngLastRow As Long, x As Long, sResCode As Variant, rngRescodeLookup As Range On Error GoTo err Set rngRescodeLookup = Range("labor_actuals_macro.xls!RES_CODE_LOOKUP") 'delete header row ActiveSheet.Range("A1").EntireRow.Delete 'determine last row lngLastRow = ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell) .Row 'insert colum for cecode ActiveSheet.Columns(7).EntireColumn.Insert 'loop through each row and lookup name in lookup table For x = 1 To lngLastRow sResCode = Application.WorksheetFunction.VLookup(Cells(x, 6).Value, rngRescodeLookup, 2) Next x Exit Sub err: MsgBox "Error" & err & ": " & Error(err) End Sub ------end code--------- I get to the part where the vlookup and it returns a value on the current sheet...not the value from the lookup table in the other book. What am I doing wrong? Thanks, Woody |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
vlookup VBA code | Excel Discussion (Misc queries) | |||
VLOOKUP as a vb code | Excel Discussion (Misc queries) | |||
Using VLOOKUP in VBA code | Excel Worksheet Functions | |||
what is the VBA code for VLOOKUP? | Excel Programming | |||
Help with Vlookup code | Excel Programming |