Consulting

Results 1 to 7 of 7

Thread: Accessing Excel Tab data from Button

  1. #1
    VBAX Regular
    Joined
    Nov 2015
    Posts
    43
    Location

    Accessing Excel Tab data from Button

    I have two tabs 1. Detail 2. Summary

    I have created the buttons in the excel 1. Detail 2. Summary

    I am hiding the tabs from the excel. I would like to show the content of detail tab when I click on detail button. Same way when click on summary button show summary content.

    Any suggestion where to put the vba code

  2. #2
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,726
    Location
    I am hiding the tabs from the excel.
    One worksheet has to be visible (making 3) so put the buttons on that sheet
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  3. #3
    VBAX Regular
    Joined
    Nov 2015
    Posts
    43
    Location
    Yes. I put the button on Sheet#3 . Can you tell me what code I should put in the button?

  4. #4
    VBAX Expert
    Joined
    Aug 2004
    Posts
    810
    Location
    put code into appropriate button and of course your sheet name as well
    Worksheets("Detail").Visible = Not Worksheets("Detail").Visible
    Worksheets("Summary").Visible = Not Worksheets("Summary").Visible

  5. #5
    VBAX Regular
    Joined
    Nov 2015
    Posts
    43
    Location
    Paul_Hossler

    See the attached test.xlsm file . I created 2 buttons on sheet2. I would like to display content from sheet1 when click on button1
    and content from sheet3 , when click on button2. I would like to preseve the same column labels, color, format as it was in the original
    sheet1 and sheet3 tabs. The result will display in sheet2.

    See my code is somewhat working but not able to retain the original format. Any suggestion.
    Attached Files Attached Files

  6. #6
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,726
    Location
    Sounds something like this -- see the attachment

    Option Explicit
    Sub Showsheet1()
        Worksheets("Sheet2").Range("A10:M100").Clear
        With Worksheets("Sheet1")
            Range(.Cells(1, 1), .Cells(13, 5)).Copy   ' copy output sheet column 1 to column 6  - Copying Avanir Data
        End With
        
        Application.ScreenUpdating = False
        Range("A10").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
        Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
        Range("A10").Select
        Application.ScreenUpdating = True
    End Sub
    
    Sub Showsheet3()
        Worksheets("Sheet2").Range("A10:M100").Clear
        With Worksheets("Sheet3")
            Range(.Cells(1, 1), .Cells(13, 11)).Copy   ' copy output sheet column 1 to column 6  - Copying Avanir Data
        End With
        
        Application.ScreenUpdating = False
        Range("A10").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
        Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
        Range("A10").Select
        Application.ScreenUpdating = True
    End Sub
    Attached Files Attached Files
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  7. #7
    VBAX Regular
    Joined
    Nov 2015
    Posts
    43
    Location
    Paul_Hossler : Thanks you very much for your time and effort. This issue have been resolved. Many thanks.

Posting Permissions

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