![]() |
Macro Run on Cell Entry
Probably a simple thing for a lot of you, but can anyone give me the code to run a macro on cell entry:
1. If the cell is unprotected 2. If the cell is protected Thanks! Michael |
Macro Run on Cell Entry
You can use the worksheet_selectionchange event to track when the cell is
entered. It should be placed on the worksheet module for the sheet of interest. I am assuming that your worksheet is protected and some of the cells are locked while others are not. If you want it to work for any cell on the worksheet, try: Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Locked = True Then Call Sub1 Else Call Sub2 End If End Sub If you want it to work for a specific cell you can use: Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Address = "$B$6" Then If Target.Locked = True Then Call Sub1 Else Call Sub2 End If End If End Sub Best, Dan "Michael Excel Dude" wrote: Probably a simple thing for a lot of you, but can anyone give me the code to run a macro on cell entry: 1. If the cell is unprotected 2. If the cell is protected Thanks! Michael -- Michael Excel Dude |
Great! Thanks Dan.
Quote:
|
All times are GMT +1. The time now is 03:07 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com