ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to run a macro upon a cell click (https://www.excelbanter.com/excel-programming/394210-how-run-macro-upon-cell-click.html)

Banzai

How to run a macro upon a cell click
 
I have a macro that runs a pop-up calendar and applies the date selected
from within the calendar to the currently selected cell.

As default I have to run this manually via tools macromacrosrun.

My question is, how do I force this so that as soon as the user clicks on
the cell that particular macro (OpenCalendar) is run and the calendar is
opened for populating the cell that has just been clicked.

If possible i'd also like to limit any user entry for certain cells other
than that populated by the calendar macro.

Thanks in advance



Jim Thomlinson

How to run a macro upon a cell click
 
Right click the sheet tab and select view code. This take you to the VBE.
Just above the Code Window are 2 drop down combo's. Change the one on the
left to Worksheet. This gives you access to worksheet event code. The
different events are listed in the drop down on the right. When you select
one it will drop a code stub in for that event. Note that for selection
change there is an arguement Target which is the cell(s) that were just
selected...

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
MsgBox Target.Address
End Sub

So you want something like...
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$A$1" then Call OpenCalendar
End Sub


--
HTH...

Jim Thomlinson


"Banzai" wrote:

I have a macro that runs a pop-up calendar and applies the date selected
from within the calendar to the currently selected cell.

As default I have to run this manually via tools macromacrosrun.

My question is, how do I force this so that as soon as the user clicks on
the cell that particular macro (OpenCalendar) is run and the calendar is
opened for populating the cell that has just been clicked.

If possible i'd also like to limit any user entry for certain cells other
than that populated by the calendar macro.

Thanks in advance




Gord Dibben

How to run a macro upon a cell click
 
See how Ron de Bruin does it.

http://www.rondebruin.nl/calendar.htm

Note the "more information" link to download mscal.ocx if needed.


Gord Dibben MS Excel MVP

On Thu, 26 Jul 2007 18:08:14 GMT, "Banzai" wrote:

I have a macro that runs a pop-up calendar and applies the date selected
from within the calendar to the currently selected cell.

As default I have to run this manually via tools macromacrosrun.

My question is, how do I force this so that as soon as the user clicks on
the cell that particular macro (OpenCalendar) is run and the calendar is
opened for populating the cell that has just been clicked.

If possible i'd also like to limit any user entry for certain cells other
than that populated by the calendar macro.

Thanks in advance



Banzai

How to run a macro upon a cell click
 

"Gord Dibben" <gorddibbATshawDOTca wrote in message
...
See how Ron de Bruin does it.

http://www.rondebruin.nl/calendar.htm

Note the "more information" link to download mscal.ocx if needed.


Gord Dibben MS Excel MVP

On Thu, 26 Jul 2007 18:08:14 GMT, "Banzai" wrote:

I have a macro that runs a pop-up calendar and applies the date selected
from within the calendar to the currently selected cell.

As default I have to run this manually via tools macromacrosrun.

My question is, how do I force this so that as soon as the user clicks on
the cell that particular macro (OpenCalendar) is run and the calendar is
opened for populating the cell that has just been clicked.

If possible i'd also like to limit any user entry for certain cells other
than that populated by the calendar macro.

Thanks in advance



Seen that, but I don't (think) it answers my question




All times are GMT +1. The time now is 10:24 AM.

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