worksheetfunction
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, |
worksheetfunction
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, |
All times are GMT +1. The time now is 11:07 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com