Consulting

Results 1 to 4 of 4

Thread: Macro to show Worksheet

  1. #1
    VBAX Newbie
    Joined
    Sep 2010
    Posts
    4
    Location

    Macro to show Worksheet

    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.

    [vba]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[/vba]
    Last edited by NRG; 10-02-2010 at 05:57 PM.

  2. #2
    VBAX Newbie
    Joined
    Sep 2010
    Posts
    4
    Location
    anyone?

  3. #3
    VBAX Mentor
    Joined
    Jun 2004
    Posts
    363
    Location
    something like this should work
    [VBA]Dim sSheet As String
    sSheet = Application.InputBox("ID", "ID", Type:=2)
    Worksheets(sSheet).Visible = True[/VBA]

  4. #4
    [VBA]
    Sub HideSHT()
    Dim sSheet As String
    sSheet = Application.InputBox("ID", "ID", Type:=2)
    Sheets("Sheet" & sSheet).Visible = False
    End Sub
    [/VBA]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •