View Full Version : Macro to show Worksheet

10-02-2010, 05:38 PM
Hi Guys,

I have a cmd button when clicked promts the user for a client ID. A exel sheet is presented after populated by data based on the client ID.

my logic in this is to have a inputbox attached to a variable (obviously) but is there someway to have the excel sheet use this variable as well?

im also having trouble with the actual code to get the worksheet to pop up after the input box is filed.

havnt done much but incase anyone needs it.

Private Sub cmdReport_Click()
Dim varInput As String
Dim varWorksheet As Worksheet
Set varWorksheet = Application.Workbooks("work.xls").Worksheets("Report1")

varInput = InputBox("Please enter your client ID")

End Sub

10-03-2010, 03:14 AM

10-03-2010, 06:24 PM
something like this should work
Dim sSheet As String
sSheet = Application.InputBox("ID", "ID", Type:=2)
Worksheets(sSheet).Visible = True

10-09-2010, 12:51 PM
Sub HideSHT()
Dim sSheet As String
sSheet = Application.InputBox("ID", "ID", Type:=2)
Sheets("Sheet" & sSheet).Visible = False
End Sub