PC Review


Reply
Thread Tools Rate Thread

Determining Cell within Range

 
 
Pablo
Guest
Posts: n/a
 
      27th Feb 2008
I am needing to determine if a selected cell is within a certain range. Below
is something that I have tried, but it only returns a 400 error.

Sub FindRange()
Dim rngMyRange As Range

Set rngMyRange = Worksheets("Sheet1").Range(A1, G20)

If ActiveCell.Select = rngMyRange Then
MsgBox ("Good Job")
Else
MsgBox ("Out of Bounds")
End If

End Sub
 
Reply With Quote
 
 
 
 
FSt1
Guest
Posts: n/a
 
      27th Feb 2008
hi
you are trying to set the activecell to equal an entire range.
try this
sub FindRange()
Dim rngMyRange As Range
Set rngMyRange = Worksheets("Sheet1").Range("A1:G20")
If Not Application.Intersect(ActiveCell, rngMyRange) Is Nothing Then
MsgBox ("Good Job")
Else
MsgBox ("Out of Bounds")
End If
End Sub

regards
FSt1

"Pablo" wrote:

> I am needing to determine if a selected cell is within a certain range. Below
> is something that I have tried, but it only returns a 400 error.
>
> Sub FindRange()
> Dim rngMyRange As Range
>
> Set rngMyRange = Worksheets("Sheet1").Range(A1, G20)
>
> If ActiveCell.Select = rngMyRange Then
> MsgBox ("Good Job")
> Else
> MsgBox ("Out of Bounds")
> End If
>
> End Sub

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Determining if a cell/range is in error? Chrisso Microsoft Excel Programming 3 12th May 2008 08:02 AM
Determining Range of selected cell mark.diffley@gmail.com Microsoft Excel Programming 2 5th Dec 2006 06:49 AM
Problem determining whether a cell is within a Range =?Utf-8?B?U2FlT25nSmVlTWE=?= Microsoft Excel Programming 2 18th Nov 2006 12:45 AM
Range.Find returns cell outside of range when range set to single cell Frank Jones Microsoft Excel Programming 12 10th Jun 2004 04:22 AM
Determining range Mike Macgowan Microsoft Excel Programming 3 31st Oct 2003 11:55 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:51 AM.