PDA

View Full Version : Macro to show Worksheet



NRG
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")

MainMenu.Hide
varInput = InputBox("Please enter your client ID")
varWorksheet.Show?

End Sub

NRG
10-03-2010, 03:14 AM
anyone?

mbarron
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

omnibuster
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