ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Activate event (https://www.excelbanter.com/excel-programming/276950-activate-event.html)

Lynn[_3_]

Activate event
 
I would like a macro to run ONLY ONCE when SheetX is
activated. I would then like cell A1 on SheetX to be
selected. How do I get this to work so that the macro does
not keep running again and again when cell A1 on SheetX is
selected?

Lynn[_3_]

Activate event
 
Private Sub Worksheet_Activate()
FdrExtract
Sheets("BOM & Price").Select
Range("A1").Select
End Sub

The problem occurs when sheet BOM & Price is
selected...the FdrExtract macro runs again and I end up in
an infinite loop.


-----Original Message-----
Post your macro here.
"Lynn" wrote in message
...
I would like a macro to run ONLY ONCE when SheetX is
activated. I would then like cell A1 on SheetX to be
selected. How do I get this to work so that the macro

does
not keep running again and again when cell A1 on SheetX

is
selected?



.


Lynn[_3_]

Activate event
 
Thanks Tom!
-----Original Message-----
In the sheet module at the top:

Dim bBlockcode as Boolean

Private Sub Worksheet_Activate()
if bBlockCode then exit sub
Range("A1").Select
bBlockCode = True
End If
End Sub

--
Regards,
Tom Ogilvy


Lynn wrote in message
...
I would like a macro to run ONLY ONCE when SheetX is
activated. I would then like cell A1 on SheetX to be
selected. How do I get this to work so that the macro

does
not keep running again and again when cell A1 on SheetX

is
selected?



.



All times are GMT +1. The time now is 06:16 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com