Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Find a string in a range and return two values based on offsets
I am looking to do something along the lines of a vlookup for a program I am
writing. I am looking in a specific range ("A2:S21") for a value that is contained in a label. I would like to do a vlookup for this, but I am having trouble getting it to work. It has to be an exact match for the value in column A with the caption of my label, and return the Integer values in columns R and S from the same row. Any suggestions? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Find a string in a range and return two values based on offsets
Dim res as Variant
Dim i1 as Integer, i2 as Integer res = Application.Vlookup(myVal, Range("A2:S21"),18,0) if not iserror(res) then i1 = res i2 = Application.Vlookup(myVal,Range("A2,S21"),19,0) else msgbox "Not found" End if another Dim rng as Range, res as Variant Dim i1 as Integer, i2 as Integer set rng = Range("A2:A21") res = Application.Match(myVal,rng,0) if not iserror(res) then i1 = rng(res).offset(0,17).Value i2 = rng(res).offset(0,18).Value Else msgbox "Not found" End if -- Regards, Tom Ogilvy "Aaron Dyck" wrote in message ... I am looking to do something along the lines of a vlookup for a program I am writing. I am looking in a specific range ("A2:S21") for a value that is contained in a label. I would like to do a vlookup for this, but I am having trouble getting it to work. It has to be an exact match for the value in column A with the caption of my label, and return the Integer values in columns R and S from the same row. Any suggestions? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Return range of cell values based on current date | Excel Worksheet Functions | |||
Find and return data based on a range | Excel Programming | |||
Return Range of Numerical Values in Single Column based on Frequency Percentage | Excel Worksheet Functions | |||
Dynamic Find and Replace String Within Functions Based on Column Values | Excel Programming | |||
Search/Filter to find values in another range based on two cell values | Excel Programming |