![]() |
Automatically starting macros
Can I get a macro to start once a cell range is changed?
I want to validate fixed input to a cell which will provide a dropdown menu of selections to pick from. My question is can I get a marco to run once a new selection is entered into the cell. |
Automatically starting macros
Right click on the sheet tab you want to react to the change and select view
code. Fust above the code window are 2 drop down menus. Change the one on the left from General to Worksheet (A code stub will be added which we can delete later). the drop down on the right now lists all of the events that you can catch in a worksheet. Select the Change event and a code stub like this will be added... Private Sub Worksheet_Change(ByVal Target As Range) End Sub Target is a refence to the cell/s that have been changed so something like this will catch a specific cell... Private Sub Worksheet_Change(ByVal Target As Range) if target.address = "$A$1" then msgbox target.value End Sub -- HTH... Jim Thomlinson "Shawn777" wrote: Can I get a macro to start once a cell range is changed? I want to validate fixed input to a cell which will provide a dropdown menu of selections to pick from. My question is can I get a marco to run once a new selection is entered into the cell. |
Automatically starting macros
Thank you, it took a few trys but I got it to work.
"Jim Thomlinson" wrote: Right click on the sheet tab you want to react to the change and select view code. Fust above the code window are 2 drop down menus. Change the one on the left from General to Worksheet (A code stub will be added which we can delete later). the drop down on the right now lists all of the events that you can catch in a worksheet. Select the Change event and a code stub like this will be added... Private Sub Worksheet_Change(ByVal Target As Range) End Sub Target is a refence to the cell/s that have been changed so something like this will catch a specific cell... Private Sub Worksheet_Change(ByVal Target As Range) if target.address = "$A$1" then msgbox target.value End Sub -- HTH... Jim Thomlinson "Shawn777" wrote: Can I get a macro to start once a cell range is changed? I want to validate fixed input to a cell which will provide a dropdown menu of selections to pick from. My question is can I get a marco to run once a new selection is entered into the cell. |
Automatically starting macros
"Shawn777" wrote: Thank you, it took a few trys but I got it to work. "Jim Thomlinson" wrote: Right click on the sheet tab you want to react to the change and select view code. Fust above the code window are 2 drop down menus. Change the one on the left from General to Worksheet (A code stub will be added which we can delete later). the drop down on the right now lists all of the events that you can catch in a worksheet. Select the Change event and a code stub like this will be added... Private Sub Worksheet_Change(ByVal Target As Range) End Sub Target is a refence to the cell/s that have been changed so something like this will catch a specific cell... Private Sub Worksheet_Change(ByVal Target As Range) if target.address = "$A$1" then msgbox target.value End Sub -- HTH... Jim Thomlinson "Shawn777" wrote: Can I get a macro to start once a cell range is changed? I want to validate fixed input to a cell which will provide a dropdown menu of selections to pick from. My question is can I get a marco to run once a new selection is entered into the cell. I also wanted a macro to run automatically, but when a particular worksheet is opened. The Worksheet - Activate selection worked fine. Each time I now open the worksheet the marco automatically updates its data analysis from another worksheet. Great ! |
Automatically starting macros
"Shawn777" wrote: Can I get a macro to start once a cell range is changed? I want to validate fixed input to a cell which will provide a dropdown menu of selections to pick from. My question is can I get a marco to run once a new selection is entered into the cell. See the other answers about Worksheet Change. It also works if you want a macro to run when the sheet is activated. Choose Worksheet - Activate and put your code there. I have it to automatically update an analysis of data from another sheet. |
All times are GMT +1. The time now is 11:07 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com