Excel VBA Problem

  • Thread starter Thread starter abbeville
  • Start date Start date
A

abbeville

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
 
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
 
This picks the value from cell B1

Sub Test()
Dim strMacroName
strMacroName = "Week" & CStr(ActiveSheet.Cells(1, 2).Value)
Application.Run (strMacroName)
End Sub
 
Thank You for your help. I tried Greg Wilson's first & it did exactl
what I wanted.

abbevill
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top