Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Check if cell value is found in a seperate range of values


How can I check if a cell's value is found within the values of a range
of values?

For instance:

In the range from say A3:A8 = [3,3,4,5,1,3]
A1 = 3

I want the VBA function to return TRUE.

Something similar to this

Function InRange(Range1 As Range, Range2 As Range) As Boolean
' returns True if Range1 is within Range2
Dim InterSectRange As Range
Set InterSectRange = Application.Intersect(Range1, Range2)
InRange = Not InterSectRange Is Nothing
Set InterSectRange = Nothing
End Function


But base it's check on values, not just addresses.

Thanks a million!


--
wilby31
------------------------------------------------------------------------
wilby31's Profile: http://www.excelforum.com/member.php...o&userid=27287
View this thread: http://www.excelforum.com/showthread...hreadid=476415

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Check if cell value is found in a seperate range of values

Function InRange(Range1 As Range, Range2 As Range) As Boolean
' returns True if Range1 is within Range2
InRange = Application.CountIf(Range2, Range1) 0
End Function

if you must use VBA.

You could just use a worksheet formula of

=COUNTIF(A3:A8,A1)0

--

HTH

RP
(remove nothere from the email address if mailing direct)


"wilby31" wrote in
message ...

How can I check if a cell's value is found within the values of a range
of values?

For instance:

In the range from say A3:A8 = [3,3,4,5,1,3]
A1 = 3

I want the VBA function to return TRUE.

Something similar to this

Function InRange(Range1 As Range, Range2 As Range) As Boolean
' returns True if Range1 is within Range2
Dim InterSectRange As Range
Set InterSectRange = Application.Intersect(Range1, Range2)
InRange = Not InterSectRange Is Nothing
Set InterSectRange = Nothing
End Function


But base it's check on values, not just addresses.

Thanks a million!


--
wilby31
------------------------------------------------------------------------
wilby31's Profile:

http://www.excelforum.com/member.php...o&userid=27287
View this thread: http://www.excelforum.com/showthread...hreadid=476415



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
Check the interval of a cell withni a range of values dakke Excel Discussion (Misc queries) 1 February 15th 08 04:00 AM
Check if rounded cell values fall within a range vertigo Excel Discussion (Misc queries) 2 April 24th 07 11:34 AM
seperate two values fromone cell into 2 cells Darius Excel Worksheet Functions 3 February 13th 07 05:02 PM
Q: check a range values JIM.H. Excel Discussion (Misc queries) 2 October 21st 05 12:26 AM
Check if a value is found twice in a range François Excel Programming 3 May 13th 05 12:52 PM


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