Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 846
Default See if cell is in Range

Thanks for taking the time to read my question.

I'm passing a string that is a cell reference to a function. In that
function I want to determine if that cell reference is within a predetermined
range. Not sure how to do that. Right now I have:

Function CheckRange(TheSheet As String, TheCell As Range) As Boolean

If TheSheet = "Sheet1" Then
if TheCell In Range("B4:B30") then 'This line is red as it is incorrect
CheckRange = True
End If

What do I use instead of "In"?

Thanks,

Brad
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default See if cell is in Range

Brad
Use something like:
If Intersect(ThisRange, ThatRange) is Nothing Then
This says if ThisRange is NOT a part of ThatRange. If you want the
opposite, stick a Not in front of Intersect. HTH Otto

"Brad" wrote in message
...
Thanks for taking the time to read my question.

I'm passing a string that is a cell reference to a function. In that
function I want to determine if that cell reference is within a
predetermined
range. Not sure how to do that. Right now I have:

Function CheckRange(TheSheet As String, TheCell As Range) As Boolean

If TheSheet = "Sheet1" Then
if TheCell In Range("B4:B30") then 'This line is red as it is incorrect
CheckRange = True
End If

What do I use instead of "In"?

Thanks,

Brad


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 846
Default See if cell is in Range

Found Answer Here

http://www.exceltip.com/st/Determine...Excel/484.html


"Brad" wrote:

Thanks for taking the time to read my question.

I'm passing a string that is a cell reference to a function. In that
function I want to determine if that cell reference is within a predetermined
range. Not sure how to do that. Right now I have:

Function CheckRange(TheSheet As String, TheCell As Range) As Boolean

If TheSheet = "Sheet1" Then
if TheCell In Range("B4:B30") then 'This line is red as it is incorrect
CheckRange = True
End If

What do I use instead of "In"?

Thanks,

Brad

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
HELP W/ VBA: SELECT RANGE, ALLCAPS, CELL COLOR, RETURN TO BLANK CELL/PATTERN CELL [email protected] Excel Programming 5 June 28th 08 07:49 PM
NEED VBA TO SELECT A CELL; NOTE THE CELL VALUE;COPYADJ CELL;FIND CELL VALUE IN A RANGE AND SO ON CAPTGNVR Excel Programming 2 July 8th 07 04:18 PM
Selecting range in list of range names depending on a cell informa Courreges Excel Discussion (Misc queries) 2 June 19th 06 10:59 AM
Change cell colour for a cell or range within a predefined range Martin[_21_] Excel Programming 2 May 23rd 05 06:16 PM
Range.Find returns cell outside of range when range set to single cell Frank Jones Excel Programming 12 June 10th 04 04:22 AM


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