Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Match Command


Dear Friends,

I need code for to find the record through macth command instead of
vlookup command. It is because the data is not in a sort order, and i
don't want to change the sorting order of the original data.

When the data found then select the 3rd col of the row in a textbox1.

Thanks in advance

Syed Haider Ali


--
Syed Haider Ali
------------------------------------------------------------------------
Syed Haider Ali's Profile: http://www.excelforum.com/member.php...o&userid=21994
View this thread: http://www.excelforum.com/showthread...hreadid=397469

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Match Command

You can use =vlookup() with data that isn't sorted. Just make sure you specify
False as the 4th argument.

=vlookup(a1,sheet2!a:d,3,false)

In code...

dim res as variant
dim myLookupRange as range
dim myCell as range

set mycell = worksheets("sheet1").range("a1")
set mylookuprange = worksheets("sheet2").range("A:D")

res = application.vlookup(mycell.value, mylookuprange,3,false)

if iserror(res) then
'not found
else
msgbox res
end if

====
I'm not sure what the 3rd column of the row in a textbox1 means.


Syed Haider Ali wrote:

Dear Friends,

I need code for to find the record through macth command instead of
vlookup command. It is because the data is not in a sort order, and i
don't want to change the sorting order of the original data.

When the data found then select the 3rd col of the row in a textbox1.

Thanks in advance

Syed Haider Ali

--
Syed Haider Ali
------------------------------------------------------------------------
Syed Haider Ali's Profile: http://www.excelforum.com/member.php...o&userid=21994
View this thread: http://www.excelforum.com/showthread...hreadid=397469


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Match Command

U can use match function to index the column within vlookup as follows

suppose your data range is b2:g10
b2:g2 is a header for your table, col b is first colum in the table.
let's say that your header has a column labeled col3 and that xyz is a
record listed in the first column of your table.

vlookup () requires that first column in data range has record u r
looking up, this is the row anchor. u can combine the match function to
identify the column within the vlookup function as below:

=VLOOKUP("xyz", B2:G10, MATCH("col3",B2:G2,0),FALSE)

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
Trying to get a decimal point using Match command nynybmbc Excel Discussion (Misc queries) 4 November 16th 07 04:38 PM
Pivot Table Error Message - "Command Text not set for command obje Jeff Divian Excel Discussion (Misc queries) 0 November 7th 07 10:26 PM
QUESTION with Match command and OFFSET alomega Excel Programming 2 February 9th 05 08:11 PM
I want to combine a "match" command with a copy and paste command. alomega Excel Programming 1 February 9th 05 05:52 PM
How Do I Expand A Set Range In The Match Command Minitman[_4_] Excel Programming 2 April 25th 04 05:49 AM


All times are GMT +1. The time now is 06:09 PM.

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

About Us

"It's about Microsoft Excel"