LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Comparing a vba variable to a range of cells

This should work...

If Not IsError(Range("AnyCups").Find(NewCupSN1.Value, _
LookAt:=xlPart, MatchCase:=False)) Then

where the xlPart tells the Find function to find the text within any single
cell within the AnyCups range even if the text is embedded within a larger
text string in that cell... use xlWhole if you want the match to be for a
cell's entire content.

--
Rick (MVP - Excel)


"ed" wrote in message
...
Howdy!

I'm having some difficulty figuring out how to do the following, or
even if it can be done.

I've got a variable value that's a text string that is determined by
user entry on a form. I need to compare that variable to a range of
cells and if it appears in ANY cell in that range return a message
box. The range of cells is assigned a name through the define name
function.

The primary problem I've got is this needs to be nested in an IF
statement.

This may look a little silly becuase its not a valid statement, but in
essence what I need is this:

IF NewCupSN1.value = Names("AllCups").ANY.value Then
blah blah blah........

Any guidance would be much appreciated.


 
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
Sum Variable Range of Cells ryguy7272 Excel Programming 2 August 17th 09 05:47 PM
COMPARING TEXT IN A RANGE OF CELLS AND DISPLAY IT IN ANOTHER. John Excel Worksheet Functions 1 February 25th 09 12:35 PM
Using a variable for range of cells Chart_Maker_Wonderer Excel Discussion (Misc queries) 3 March 4th 07 12:05 PM
Comparing a single cell to range of cells BobC[_3_] Excel Programming 2 May 20th 04 06:44 PM
Range.Select with variable cells ? [email protected] Excel Programming 2 October 29th 03 08:43 PM


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

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"