Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Current Cell location | Excel Worksheet Functions | |||
Macro - save to current location vs excel default location | Excel Discussion (Misc queries) | |||
VBA to specify chart location as obj in current sheet? | Charts and Charting in Excel | |||
RefEdit updating Current Cell location | Excel Programming | |||
Saving a TXT file keeping its current location | Excel Programming |