Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Return range of cell values based on current date WingH Excel Worksheet Functions 1 March 31st 10 07:35 PM
Find and return data based on a range egeorge4[_2_] Excel Programming 7 June 18th 06 12:43 PM
Return Range of Numerical Values in Single Column based on Frequency Percentage Sam via OfficeKB.com Excel Worksheet Functions 9 October 28th 05 11:01 PM
Dynamic Find and Replace String Within Functions Based on Column Values [email protected] Excel Programming 0 October 13th 05 06:16 PM
Search/Filter to find values in another range based on two cell values Andy Excel Programming 2 April 29th 04 04:08 PM


All times are GMT +1. The time now is 01:37 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"