Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi all,
I'm trying to have a conditional statement to reference if a cell is active. If a cell is active, then run some code, if it is not active, then run some other code. Any help is most gracious! Thanks, Keith |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Keith,
If ActiveCell.Address = "$A$1" Then RunSomeCode Else RunSomeOtherCode End If You may want to check the sheet name as well - but that depends on your workbook structure HTH, Bernie MS Excel MVP "Keith in Portland" <Keith in wrote in message ... Hi all, I'm trying to have a conditional statement to reference if a cell is active. If a cell is active, then run some code, if it is not active, then run some other code. Any help is most gracious! Thanks, Keith |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You might try building your code in the Worksheet_SelectionChange event.
When in the VBA window, just double click the sheet where you want the code to operate. In the code window there are two dropdowns at the top. Select Worksheet in the left one, and SelectionChange in the right. "Target" is the range in process of being selected. example: Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Address = "$A$1" Then [put some code here] End If End Sub "Keith in Portland" wrote: Hi all, I'm trying to have a conditional statement to reference if a cell is active. If a cell is active, then run some code, if it is not active, then run some other code. Any help is most gracious! Thanks, Keith |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Whoo-hoo!! It worked and you rock!
And thanks to B Lynn B, too. Thanks y'all!! Peace, Keith "Bernie Deitrick" wrote: Keith, If ActiveCell.Address = "$A$1" Then RunSomeCode Else RunSomeOtherCode End If You may want to check the sheet name as well - but that depends on your workbook structure HTH, Bernie MS Excel MVP "Keith in Portland" <Keith in wrote in message ... Hi all, I'm trying to have a conditional statement to reference if a cell is active. If a cell is active, then run some code, if it is not active, then run some other code. Any help is most gracious! Thanks, Keith . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Row select mode to highlight active row of active cell | Excel Discussion (Misc queries) | |||
getting the selected range and active cell of a non active worksheetsheet | Excel Programming | |||
run macro although blinking cursor is active in an active cell | Excel Programming | |||
referring to formula in a non active cell from active cell | Excel Discussion (Misc queries) | |||
I need to sort an active sheet using the col of the active cell | Excel Programming |