ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel VBA Problem (https://www.excelbanter.com/excel-programming/306347-excel-vba-problem.html)

abbeville[_2_]

Excel VBA Problem
 
I have 35 macros named "Week 1" etc. to "Week 35". Is it possible t
build a macro that will run each macro according to a cell value? i.e
if cell value = 1 it would run "Week 1", if cell value = 23 it woul
run "Week 23". Can anyone help me?
abbevill

--
Message posted from http://www.ExcelForum.com


Greg Wilson[_4_]

Excel VBA Problem
 
Sub SelectMacro()
Dim x As Integer
x = ActiveCell.Value
On Error Resume Next
Application.Run ("Week" & x)
On Error GoTo 0
End Sub


Regards,
Greg


-----Original Message-----
I have 35 macros named "Week 1" etc. to "Week 35". Is it

possible to
build a macro that will run each macro according to a

cell value? i.e.
if cell value = 1 it would run "Week 1", if cell value =

23 it would
run "Week 23". Can anyone help me?
abbeville


---
Message posted from http://www.ExcelForum.com/

.


Filips Benoit

Excel VBA Problem
 
This picks the value from cell B1

Sub Test()
Dim strMacroName
strMacroName = "Week" & CStr(ActiveSheet.Cells(1, 2).Value)
Application.Run (strMacroName)
End Sub

"abbeville " wrote in message
...
I have 35 macros named "Week 1" etc. to "Week 35". Is it possible to
build a macro that will run each macro according to a cell value? i.e.
if cell value = 1 it would run "Week 1", if cell value = 23 it would
run "Week 23". Can anyone help me?
abbeville


---
Message posted from http://www.ExcelForum.com/




abbeville[_3_]

Excel VBA Problem
 
Thank You for your help. I tried Greg Wilson's first & it did exactl
what I wanted.

abbevill

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 01:28 PM.

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