Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 921
Default Check current location

Hi,

I'm trying to create a macro that will only run when the active cell is in
certain locations. If the active cell is not in the correct location I want
to display an error message.

Any ideas gratefully received.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Check current location

Jeff,
Depends how you determine the correct location:

Const MAXROW As Long = 10
If ActiveCell.Row MAXROW Then
MsgBox "Must be on/before row " & MAXROW
End If

Const MAXCOL As Long = 10
If ActiveCell.Column MAXCOL Then
MsgBox "Must be on/before column " & MAXCOL
End If

Const OK_RANGE As String = "D3:M26"
If Intersect(ActiveCell, Range(OK_RANGE)) Is Nothing Then
MsgBox "Must be in the range " & OK_RANGE
End If

NickHK

"Jeff" wrote in message
...
Hi,

I'm trying to create a macro that will only run when the active cell is in
certain locations. If the active cell is not in the correct location I

want
to display an error message.

Any ideas gratefully received.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Check current location

If Intersect(Activecell, Range("H1:M10")) Is Nothing Then
MsgBox "Not in correct location"
End If

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Jeff" wrote in message
...
Hi,

I'm trying to create a macro that will only run when the active cell is in
certain locations. If the active cell is not in the correct location I
want
to display an error message.

Any ideas gratefully received.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 921
Default Check current location

Perfect,

Thanks very much

"Bob Phillips" wrote:

If Intersect(Activecell, Range("H1:M10")) Is Nothing Then
MsgBox "Not in correct location"
End If

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Jeff" wrote in message
...
Hi,

I'm trying to create a macro that will only run when the active cell is in
certain locations. If the active cell is not in the correct location I
want
to display an error message.

Any ideas gratefully received.





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
Current Cell location HRHRLBS Excel Worksheet Functions 1 April 16th 09 07:38 PM
Macro - save to current location vs excel default location leezard Excel Discussion (Misc queries) 0 October 28th 08 03:04 PM
VBA to specify chart location as obj in current sheet? Dr Dan[_2_] Charts and Charting in Excel 6 February 23rd 07 03:25 PM
RefEdit updating Current Cell location coco Excel Programming 1 August 6th 05 07:53 PM
Saving a TXT file keeping its current location Chichifo[_3_] Excel Programming 1 September 7th 04 07:39 PM


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