ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Starting A Macro (https://www.excelbanter.com/excel-discussion-misc-queries/118282-starting-macro.html)

zephyr

Starting A Macro
 
This week is week # 45.

I have 52 macros on a worksheet. Each one selects data for a particular week
when a button is pressed. I would like to eliminate the buttons and have the
macro start when the particular week# is typed in the cell.

If a particular week # is typed in a cell how do I get the macro to start
for the week number selected. The week number may range from 1 to 52.

Many thanks in advance.

Bob Phillips

Starting A Macro
 
Application.Run "macro_" & Range("A1").Value

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"zephyr" wrote in message
...
This week is week # 45.

I have 52 macros on a worksheet. Each one selects data for a particular

week
when a button is pressed. I would like to eliminate the buttons and have

the
macro start when the particular week# is typed in the cell.

If a particular week # is typed in a cell how do I get the macro to start
for the week number selected. The week number may range from 1 to 52.

Many thanks in advance.




Stefi

Starting A Macro
 
Are you sure that you really need 52 macros instead of having one using the
Week No as parameter? In the latter case this event sub does the job (say
cell for inputting week No is A1)

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address(False, False) = "A1" Then
Call weekmacro(Target.Value)
End If
End Sub

Regards,
Stefi
Sub weekmacro(weekno)
MsgBox "macro" & weekno
End Sub


zephyr ezt *rta:

This week is week # 45.

I have 52 macros on a worksheet. Each one selects data for a particular week
when a button is pressed. I would like to eliminate the buttons and have the
macro start when the particular week# is typed in the cell.

If a particular week # is typed in a cell how do I get the macro to start
for the week number selected. The week number may range from 1 to 52.

Many thanks in advance.



All times are GMT +1. The time now is 07:25 AM.

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