Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
hi,
i'm trying to use vlookup in vba, bt i can't get it to work. here's the thing: Dim count As Integer Dim n As Integer Dim table As String Dim look As String Dim column As Integer count = Workbooks("BDs").Worksheets("bd_lx").Range("A2").V alue column = 3 For n = 4 To count look = Workbooks("BDs").Worksheets("bd_lx").Range("B" & n).Value table = Workbooks("BDs").Worksheets("bd_lx").Range("A" & n).Value Application.WorksheetFunction.VLookup(look, rg, column, False).Select Selection.Copy Range("B:" & n).Select Selection.End(xlRight).Select ActiveCell.Offset(1, 0).Activate Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _ False, Transpose:=False Next n is it 'cause the variable array? and probably is not a range? how can i put it right? thanks a million, |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Vlookup returns string or number from column 3 - not the location of the
cell. Use match in conjunction with your rg this assumes rg is a single column range object. if it is an array, you can't use range methods like Copy and select res = application.Match(look, rg, 0) if not iserror(res) then rg(res).Select or rg(res,3).Select Clarify what rg is -- Regards, Tom Ogilvy "devnext" wrote in message ... hi, i'm trying to use vlookup in vba, bt i can't get it to work. here's the thing: Dim count As Integer Dim n As Integer Dim table As String Dim look As String Dim column As Integer count = Workbooks("BDs").Worksheets("bd_lx").Range("A2").V alue column = 3 For n = 4 To count look = Workbooks("BDs").Worksheets("bd_lx").Range("B" & n).Value table = Workbooks("BDs").Worksheets("bd_lx").Range("A" & n).Value Application.WorksheetFunction.VLookup(look, rg, column, False).Select Selection.Copy Range("B:" & n).Select Selection.End(xlRight).Select ActiveCell.Offset(1, 0).Activate Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _ False, Transpose:=False Next n is it 'cause the variable array? and probably is not a range? how can i put it right? thanks a million, |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
WorksheetFunction help | Excel Discussion (Misc queries) | |||
Can't use WorksheetFunction | Excel Discussion (Misc queries) | |||
WorksheetFunction with VBA | Excel Discussion (Misc queries) | |||
Worksheetfunction MATCH | Excel Programming | |||
Using Application.WorksheetFunction.Ln(...) in VBA | Excel Programming |