Combine macros variable help

E

Ephraim

So I've recorded a number of macros that each hide a different Week.

Sub Macro1()
' Macro1 Macro
Application.Goto Reference:="Week1"
Selection.EntireColumn.Hidden = True
End Sub
..
..
..
Sub Macro10()
' Macro10 Macro
Application.Goto Reference:="Week10"
Selection.EntireColumn.Hidden = True
End Sub

How do I create one macro to do all of this by using a variable for
the "Week number" that is provided by asking the user to select the
Week number from an input box or a drop down list?
Thanks
 
D

Don Guillett

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(e-mail address removed)
 
D

Don Guillett

Sub hidecolumn()
'Columns.Hidden = False'uncomment to unhide all first
cth = InputBox("Enter week number ie: 1 10")
mycol = "week" & cth
Range(mycol).EntireColumn.Hidden = True
End Sub
 

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

Top