ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Starting a macro from a list selection (https://www.excelbanter.com/excel-worksheet-functions/121108-starting-macro-list-selection.html)

Rich_g

Starting a macro from a list selection
 
Hello. I've got a worksheet with a column of cells that are set up to select
from a list. What I'd like to do is to be able to execute a macro each time a
list item is selected. I've used methods like ".OnEntry" before to start a
macro each time a cell is updated, but that function does not seem to be able
to sense when a cell containing a list changes the selected list-item. Is
there something similar to the .OnEntry but for lists?
Thanks so much in advance for the help!
Rich

Alok

Starting a macro from a list selection
 
Hi
You can use the Worksheets Change event
For example if the cell in which you have data validation - which shows a
list then
the following code will print each of the selected values to your Immediate
window.
You can replace that with the execution of a macro
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells(1).Address = "$A$1" Then
Debug.Print Target.Cells(1).Value
End If
End Sub


"Rich_g" wrote:

Hello. I've got a worksheet with a column of cells that are set up to select
from a list. What I'd like to do is to be able to execute a macro each time a
list item is selected. I've used methods like ".OnEntry" before to start a
macro each time a cell is updated, but that function does not seem to be able
to sense when a cell containing a list changes the selected list-item. Is
there something similar to the .OnEntry but for lists?
Thanks so much in advance for the help!
Rich


Rich_g

Starting a macro from a list selection
 
Thanks Alok. I just came across moments ago while searching through a post.
Wish I'd seen it earlier and not foolishly bothered everyone. Anyway, I tried
it and it works just great.

Thanks again!

"Alok" wrote:

Hi
You can use the Worksheets Change event
For example if the cell in which you have data validation - which shows a
list then
the following code will print each of the selected values to your Immediate
window.
You can replace that with the execution of a macro
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells(1).Address = "$A$1" Then
Debug.Print Target.Cells(1).Value
End If
End Sub


"Rich_g" wrote:

Hello. I've got a worksheet with a column of cells that are set up to select
from a list. What I'd like to do is to be able to execute a macro each time a
list item is selected. I've used methods like ".OnEntry" before to start a
macro each time a cell is updated, but that function does not seem to be able
to sense when a cell containing a list changes the selected list-item. Is
there something similar to the .OnEntry but for lists?
Thanks so much in advance for the help!
Rich


Alok

Starting a macro from a list selection
 
You are welcom.

"Rich_g" wrote:

Thanks Alok. I just came across moments ago while searching through a post.
Wish I'd seen it earlier and not foolishly bothered everyone. Anyway, I tried
it and it works just great.

Thanks again!

"Alok" wrote:

Hi
You can use the Worksheets Change event
For example if the cell in which you have data validation - which shows a
list then
the following code will print each of the selected values to your Immediate
window.
You can replace that with the execution of a macro
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells(1).Address = "$A$1" Then
Debug.Print Target.Cells(1).Value
End If
End Sub


"Rich_g" wrote:

Hello. I've got a worksheet with a column of cells that are set up to select
from a list. What I'd like to do is to be able to execute a macro each time a
list item is selected. I've used methods like ".OnEntry" before to start a
macro each time a cell is updated, but that function does not seem to be able
to sense when a cell containing a list changes the selected list-item. Is
there something similar to the .OnEntry but for lists?
Thanks so much in advance for the help!
Rich



All times are GMT +1. The time now is 08:48 PM.

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