Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 287
Default Is Active Cell in a Range?

I want to write some code like,

If Activecell is part of range whatever then
if true....
else
If fales....
End if

How do I say that?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,117
Default Is Active Cell in a Range?

how 'bout.........

Sub wheres_cell()

Dim myRange As Range
Dim c As Range

Set myRange = Range("c2:c7")

For Each c In myRange
If ActiveCell.Address = c.Address Then
MsgBox "I'm in the range :) " & c.Address
Exit Sub
Else
'do nothing
End If
Next c

MsgBox "I'm not in the range :("

End Sub


works for me. change to fit your ranges.
susan


On Jan 17, 3:55*pm, Aaron wrote:
I want to write some code like,

If Activecell is part of range whatever then
if true....
else
If fales....
End if

How do I say that?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Is Active Cell in a Range?

If intersect(activecell, range("a1:b99")) is nothing then
msgbox "not in a1:b99
else
msbox "yes, I am!"
end if


Aaron wrote:

I want to write some code like,

If Activecell is part of range whatever then
if true....
else
If fales....
End if

How do I say that?


--

Dave Peterson
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
Clearly seeing active cell in a range dsa Excel Discussion (Misc queries) 2 March 24th 08 03:22 PM
How to set active cell range to an variable Jørgen Andreassen Excel Programming 4 August 20th 07 02:37 PM
using a the active cell in a range command.... dr chuck Excel Programming 4 July 7th 06 03:03 PM
Active cell as range Patrick Simonds Excel Programming 4 May 29th 06 08:21 PM
find range name for active cell Len Excel Programming 2 November 22nd 05 02:37 PM


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