![]() |
IF a cell is active THEN...
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 |
IF a cell is active THEN...
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 |
IF a cell is active THEN...
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 |
IF a cell is active THEN...
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 . |
All times are GMT +1. The time now is 12:42 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com