+ Reply to Thread
Results 1 to 8 of 8

Select Multiple Sheets and then Hide Columns

  1. #1
    Registered User
    Join Date
    01-25-2013
    Location
    Miami, FL
    MS-Off Ver
    Excel 2010
    Posts
    9

    Thumbs up Select Multiple Sheets and then Hide Columns

    Hi All,

    I have a spreadsheet with a collection of 5 tabs.

    Sheet 1 is named Summary
    Sheet 2 is named Steve's Shop
    Sheet 3 is named Joe's Shop
    Sheet 4 is named Mary's Shop
    Sheet 5 is named Mike's Shop

    I want a marco that will highlight only Sheets 2-5 (in this example) Unhide all Columns and Rows then hide columns D-E.

    I tried the following:
    Please Login or Register  to view this content.
    But it only works in the first Tab but not the otheres. What am I missing?

    Thanks in advance.
    Last edited by jeffreybrown; 02-04-2013 at 11:16 AM. Reason: Please use code tags...Thanks.

  2. #2
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Select Multiple Sheets and then Hide Columns

    How about

    Please Login or Register  to view this content.
    HTH
    Regards, Jeff

  3. #3
    Valued Forum Contributor
    Join Date
    08-13-2012
    Location
    Gardony, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    558

    Re: Select Multiple Sheets and then Hide Columns

    I think you can't do that at once to all the sheets. Try looping through them instead.
    Also, you don't need to select the columns to hide/unhide them.
    Please Login or Register  to view this content.
    Last edited by RHCPgergo; 02-04-2013 at 11:35 AM. Reason: ooops, a little wrong

  4. #4
    Valued Forum Contributor
    Join Date
    06-19-2010
    Location
    Holywell, N Wales, UK
    MS-Off Ver
    Excel 2013
    Posts
    470

    Re: Select Multiple Sheets and then Hide Columns

    With acknowledgements to Jeff and RHCPgergo
    another one for the pot

    Please Login or Register  to view this content.
    If this was helpful then please click the small star icon at the bottom left of my post. A little appreciation goes a long way.

  5. #5
    Registered User
    Join Date
    01-25-2013
    Location
    Miami, FL
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Select Multiple Sheets and then Hide Columns

    Hi Quick Question:
    What is the LBound() To UBound(). I am understand the code which is creating the range from 0-3. But not sure how they work.
    Thanks

  6. #6
    Registered User
    Join Date
    01-25-2013
    Location
    Miami, FL
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Select Multiple Sheets and then Hide Columns

    Oh I forgot to ask to add a Scroll up to A1 for each sheet.
    I had Application.Goto Reference:=Range("a1"), Scroll:=True
    How do I convert it to work with the For - Next function?
    Thanks again!

  7. #7
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Select Multiple Sheets and then Hide Columns

    Here is at least one place to read about LBound() To UBound().

    http://www.cpearson.com/excel/VBAArrays.htm

    Please Login or Register  to view this content.
    You need to place the qualifier in front of the range so when it loops through the sheets it knows, new sheet...

    Notice how it is within the With ws statement and the dot in front of Range("A1") (the dot qualifies the range to each ws)

    Hope this help

  8. #8
    Valued Forum Contributor
    Join Date
    08-13-2012
    Location
    Gardony, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    558

    Re: Select Multiple Sheets and then Hide Columns

    LBound or UBound return the number of the first or last element in the array. (I repeat myself: they don't return the element of the array, but the ordinal number of the element.)

    LBound means lower bound and UBound means upper bound (of an array). LBound is usually 1 or 0 and UBound is the number of the last element in the array. Arrays start with element number zero by default.

+ 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