Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default search column for a specific piece of data using vba

using vba in excel 2000, wish to search a column for specific data and return
that value to another cell.
can do this using vlookup but wish to use vba
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 111
Default search column for a specific piece of data using vba

Have a look at the Find Method in help.

--
Damon Longworth

Don't miss out on the 2005 Excel User Conference
Sept 16th and 17th
Stockyards Hotel - Ft. Worth, Texas
www.ExcelUserConference.com


"dave91" wrote in message
...
using vba in excel 2000, wish to search a column for specific data and
return
that value to another cell.
can do this using vlookup but wish to use vba



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default search column for a specific piece of data using vba

I'm not quite sure why you'd want to search a column for a value and return that
value (you already have that value--just use it!).

But you could do something like

dim res as variant
dim myVal as variant
dim myRng as range

with activesheet
set myrng = .range("a:a") 'single column
end with

myVal = "asdf"

res = application.match(myval,myrng,0)
if iserror(res) then
'not found in that column
else
msgbox myrng(res).offset(0,1).value
end if

..offset(0,1) means that I want to bring back the value from one column to the
right of the range.

==========
If you want to use =vlookup()

dim res as variant
dim myRng as range
dim myVal as variant

with activesheet
set myrng = .range("a:c") 'three columns
end with

myVal = "asdf"

res = application.vlookup(myval,myrng,2,false)
if iserror(res) then
'not found in that column
else
msgbox res
end if




dave91 wrote:

using vba in excel 2000, wish to search a column for specific data and return
that value to another cell.
can do this using vlookup but wish to use vba


--

Dave Peterson
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
Find & Replace - Limit search to a specific column falena23 Excel Worksheet Functions 3 July 28th 08 03:46 PM
Displaying what column a piece of data is in Ronin898 Excel Worksheet Functions 1 October 3rd 07 03:08 PM
search column of text cellto identify those cells with specific w Ross Headifen Excel Worksheet Functions 1 July 8th 06 02:49 PM
Excel Macro Query - Search for specific text in cells of a column Mcneilius Excel Programming 2 August 29th 04 05:12 PM
Macro to search a column for a specific word and replace with wendy Excel Programming 5 January 19th 04 05:41 PM


All times are GMT +1. The time now is 04:15 PM.

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"