breynolds0431
Active Member
- Joined
- Feb 15, 2013
- Messages
- 303
- Office Version
- 365
- 2016
- Platform
- Windows
Hello. Looking for a solution to the below. I basically have a user-input file where the ID that the user enters should retrieve 3 pieces of data relevant to that ID with a VLOOKUP. The problem is that the data source is very large. I've put all the data on one excel tab, thinking that would make things more efficient, and given a named range to each group. So the VLOOKUP i have checks each range, which is obviously sluggish as each range exceeds the row limit of excel. Thank you for your time!
VBA Code:
Sub pleasehelp ()
With Application
.ScreenUpdating = False
.EnableEvents = False
.DisplayAlerts = False
.Calculation = xlCalculationManual
End With
Set wsh = Worksheets("MEDataGrab")
Workbooks.Open Filename:="C:\Desktop\MEDataFiles.xlsb"
i = 7
While wsh.Cells(i, 2) <> ""
wsh.Cells(i, 3).FormulaR1C1 = _
"=iferror(VLOOKUP(RC[-1],'MEDataFiles.xlsb'!MEData1,2,FALSE),iferror(VLOOKUP(RC[-1],'MEDataFiles.xlsb'!MEData2,2,FALSE),iferror(VLOOKUP(RC[-1],'MEDataFiles.xlsb'!MEData3,2,FALSE),"""")))"
wsh.Cells(i, 4).FormulaR1C1 = _
"=iferror(VLOOKUP(RC[-2],'MEDataFiles.xlsb'!MEData1,3,FALSE),iferror(VLOOKUP(RC[-2],'MEDataFiles.xlsb'!MEData2,3,FALSE),iferror(VLOOKUP(RC[-2],'MEDataFiles.xlsb'!MEData3,3,FALSE),"""")))"
wsh.Cells(i, 5).FormulaR1C1 = _
"=iferror(VLOOKUP(RC[-3],'MEDataFiles.xlsb'!MEData1,4,FALSE),iferror(VLOOKUP(RC[-3],'MEDataFiles.xlsb'!MEData2,4,FALSE),iferror(VLOOKUP(RC[-3],'MEDataFiles.xlsb'!MEData3,4,FALSE),"""")))"
i = i + 1
Wend
Columns("C:E").Select
Selection.Copy
Range("C1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Workbooks("MEDataFiles.xlsb").Close SaveChanges:=False
With Application
.ScreenUpdating = True
.EnableEvents = True
.DisplayAlerts = True
.Calculation = xlCalculationAutomatic
End With
End Sub