Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 76
Default Determining Cell within Range

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default Determining Cell within Range

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
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
Determining Frequency of range Leitodd Excel Worksheet Functions 2 October 16th 09 03:03 AM
Determining Range of selected cell [email protected] Excel Programming 2 December 5th 06 06:49 AM
Determining last copied range R Avery Excel Programming 2 February 13th 04 12:11 AM
Determining range Sam Carleton Excel Programming 3 October 31st 03 11:55 PM


All times are GMT +1. The time now is 08:56 PM.

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"