PC Review


Reply
Thread Tools Rate Thread

Is Active Cell in a Range?

 
 
Aaron
Guest
Posts: n/a
 
      17th Jan 2008
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?
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      17th Jan 2008
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 With Quote
 
Susan
Guest
Posts: n/a
 
      17th Jan 2008
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 <Aa...@discussions.microsoft.com> 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?


 
Reply With Quote
 
Susan
Guest
Posts: n/a
 
      17th Jan 2008
cool. mine works, but dave's is better.

susan


On Jan 17, 4:11*pm, Dave Peterson <peter...@verizonXSPAM.net> wrote:
> 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 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
getting the selected range and active cell of a non active worksheetsheet GerryGerry Microsoft Excel Programming 7 23rd Sep 2009 05:22 PM
macro to select range from active cell range name string aelbob Microsoft Excel Programming 2 14th Jul 2008 09:19 PM
active cell range Atishoo Microsoft Excel Programming 1 14th May 2008 04:16 PM
find cell address of last active cell in range Dave F Microsoft Excel Programming 2 9th Nov 2007 03:23 AM
Verify Active Cell is within a Range that changes as cell is delet =?Utf-8?B?U2hhbm5vbg==?= Microsoft Excel Programming 2 11th Feb 2006 12:01 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:13 PM.