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 for value in a range

I have a value in cell A1 on Worksheet1 that I want to
check to see if it present in column A on Worksheet2.
For instance. Cell A1 = 123 on worksheet1. I want to see
if 123 is present in a list of numbers in column A of a
different worksheet (worksheet2). If it is present in
worksheet 2, I want to copy the value of the cell to the
right of the found cell in worksheet2 to cell A1 of
worksheet3. In other words, when I find the number 123
in column A on worksheet 2, copy the value of the cell
next to it to worksheet3.

I hope that isn't too confusing.
Regards,
JC
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Search for value in a range

Put this in Sheet3, cell A1
=if(countif(Sheet2!A:A,Sheet1!A1)0,Vlookup(Sheet1 !A1,Sheet2!A:B,2,False),""
)

or in code

set rng1 = Worksheets("Sheet1").Range("A1")
set rng2 = Worksheets("Sheet2").Columns(1).Resize(,2)
set rng3 = Worksheets("Sheet3").Range("A1")
if application.Countif(rng2,rng1) 0 then
rng3value = Application.Vlookup(rng1,rng2,2,false)
End if

--
Regards,
Tom Ogilvy


"JC" wrote in message
...
I have a value in cell A1 on Worksheet1 that I want to
check to see if it present in column A on Worksheet2.
For instance. Cell A1 = 123 on worksheet1. I want to see
if 123 is present in a list of numbers in column A of a
different worksheet (worksheet2). If it is present in
worksheet 2, I want to copy the value of the cell to the
right of the found cell in worksheet2 to cell A1 of
worksheet3. In other words, when I find the number 123
in column A on worksheet 2, copy the value of the cell
next to it to worksheet3.

I hope that isn't too confusing.
Regards,
JC



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
Search range, find value in another col in corresponding row Brent E Excel Discussion (Misc queries) 3 October 1st 08 06:43 PM
Search range johnrb7865 Excel Worksheet Functions 10 September 11th 08 05:48 PM
Search for value in a range Student Excel Worksheet Functions 6 January 31st 08 12:46 AM
search within a range of cells? [email protected] Excel Discussion (Misc queries) 2 April 22nd 07 08:08 AM
Search range for text not in another range simon howard Excel Discussion (Misc queries) 3 March 28th 07 08:44 PM


All times are GMT +1. The time now is 11:38 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"