Nov 4th, 2008, 12:07 PM
#1
Thread Starter
Addicted Member
[RESOLVED] Simple Lookup Help
What is the simplest way to lookup a value using VBA in Excel? Here is what I am trying to do. For each cell in a column range I am looking at the value i.e. "05569". That value corresponds to another value in my list/table i.e. "Engine". How to I extract "Engine" and enter it into another cell? Thanks in advance for your help. I know this is an easy one but I cannot figure it out using VBA (Data Dictionary, Array, List, Function VLOOKUP, etc.)???
"05569" = "Engine"
"05579" = "Plant"
Nov 4th, 2008, 12:09 PM
#2
Re: Simple Lookup Help
If you can upload your workbook then I can give you the exact code...
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear :
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
Nov 4th, 2008, 12:21 PM
#3
Thread Starter
Addicted Member
Re: Simple Lookup Help
I'm sorry but I cannot upload the workbook. You can write the code using range("A1:A5") and returning the lookup value in range("B1:B5").
A1 = 012
A2 = 013
A3 = 014
A4 = 015
A5 = 016
012 = Mon
013 = Tue
014 = Wed
015 = Thu
016 = Fri
Nov 4th, 2008, 12:42 PM
#4
Re: Simple Lookup Help
Ok lets say (See picture Attached)
A1 = 12
A2 = 13
A3 = 14
A4 = 015
A5 = 16
and
A9 = 12
A10 = 13
A11 = 14
A12 = 15
A13 = 16
And
B9 = Mon
B10 = Tue
B11 = Wed
B12 = Thu
B13 = Fri
So if you run this code, it will do what you want... I have commented the code so that it is easy to understand...
vb Code:
Sub LookupValues()
'Put formula in Cell B1
'R9C1:R13C2 is the Range A9-B13 as mentioned above
'RC[-1] is the cell before B1 where we are picking up the value to check
Range("B1").FormulaR1C1 = "=VLOOKUP(RC[-1],R9C1:R13C2,2,0)"
'Autofill formula down... till last cell
Range("B1").AutoFill Destination:=Range("B1:B5"), Type:=xlFillDefault
End Sub
Attached Images
Last edited by Siddharth Rout; Nov 4th, 2008 at 12:45 PM .
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear :
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width