+ Reply to Thread
Results 1 to 15 of 15

Hide a Table using VBA

Hybrid View

  1. #1
    Registered User
    Join Date
    05-02-2011
    Location
    Denver, Colorado
    MS-Off Ver
    Excel 2007
    Posts
    2

    Hide a Table using VBA

    How can I hide a table in Excel 2007 using VBA? I'm looking for a way to turn them off and on programatically.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Hide a Table using VBA

    Do you mean hide the rows or columns that contain the table, or something else?
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Contributor
    Join Date
    02-07-2012
    Location
    MIA
    MS-Off Ver
    Excel 2007, 2010
    Posts
    429

    Re: Hide a Table using VBA

    You can try with:

    ActiveSheet.ListObjects("Table1").Hide
    Should work if your table name is Table1, change that according to your needs otherwise.

    I hoop that works.
    .?*??)
    `?.???.?*??)?.?*?)
    (?.?? (?.?
    Pichingualas <---
    ??????????????????????????

    Wrap your code with CODE TAGS.
    Thank those who helped you, Don't forget to add to their REPUTATION!!! (click on the star below their post).
    Please mark your threads as [SOLVED] when they are (Thread Tools->Mark thread as Solved).

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Hide a Table using VBA

    It might, if the ListObject object had a Hide method, but it doesn't.

  5. #5
    Forum Contributor
    Join Date
    02-07-2012
    Location
    MIA
    MS-Off Ver
    Excel 2007, 2010
    Posts
    429

    Re: Hide a Table using VBA

    Yeah I noticed lol :P

  6. #6
    Forum Contributor
    Join Date
    02-07-2012
    Location
    MIA
    MS-Off Ver
    Excel 2007, 2010
    Posts
    429

    Re: Hide a Table using VBA

    Maybe like so?

    Range("Table1[[#Headers],[Zone Code]:[Channel]]").Select
    ActiveSheet.HideSelection = True

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Hide a Table using VBA

    How well did that work when you tested it?

  8. #8
    Forum Contributor
    Join Date
    02-07-2012
    Location
    MIA
    MS-Off Ver
    Excel 2007, 2010
    Posts
    429

    Re: Hide a Table using VBA

    Hmm... lol

    Maybe this then:

    Range("Table1[#All]").Select
    Selection.EntireColumn.Hidden = True

  9. #9
    Forum Contributor
    Join Date
    02-07-2012
    Location
    MIA
    MS-Off Ver
    Excel 2007, 2010
    Posts
    429

    Re: Hide a Table using VBA

    Although that wouldnt hide only the table but all the columns lol

  10. #10
    Forum Contributor
    Join Date
    02-07-2012
    Location
    MIA
    MS-Off Ver
    Excel 2007, 2010
    Posts
    429

    Re: Hide a Table using VBA

    The way I see it, it's impossible to hide only the table. You need to hide either its rows or its columns.

    @shg: is this correct?

  11. #11
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Hide a Table using VBA

    Yup .

  12. #12
    Forum Contributor
    Join Date
    02-07-2012
    Location
    MIA
    MS-Off Ver
    Excel 2007, 2010
    Posts
    429

    Re: Hide a Table using VBA

    Thought so lol

    Thanks :P

  13. #13
    Registered User
    Join Date
    05-02-2011
    Location
    Denver, Colorado
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Hide a Table using VBA

    Thanks guys. So even though it's not possible to completely hide the table using VBA, is it possible to move it?

  14. #14
    Forum Expert
    Join Date
    09-27-2011
    Location
    Poland
    MS-Off Ver
    Excel 2007
    Posts
    1,312

    Re: Hide a Table using VBA

    try this code
    ActiveSheet.ListObjects("Table1").Range.Cut Destination:=Range("a11")
    check the name of your table
    Regards

    tom1977

    If You are satisfied with my solution click the small star icon on the left to say thanks.

  15. #15
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Hide a Table using VBA

    Sure. Record a macro of cutting and pasting it.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1