+ Reply to Thread
Results 1 to 3 of 3

Hiding particular columns on multiple sheets

  1. #1
    Registered User
    Join Date
    11-27-2012
    Location
    Guildford, England
    MS-Off Ver
    Excel 2003
    Posts
    1

    Hiding particular columns on multiple sheets

    hi there,

    I am new to this forum but have already found it helpful!

    Basically i have an excel file which is a template for entering in deals which can vary from 3-7 years. So I want to make it easier for the end user -by having the VBA hide colomns based upon if they are 0's i.e. if its a 5 year deal then the year 6 and year 7 wont show... etcetc. The file is about 20 sheets big and 15 of them are the same format just for differerent lines of business (these 15 are the ones i want to make more consise to the years that they represent)

    Anyway thats my waffle over, here is my current code I am using:

    Sheets(Array(ABOUT 15 SHEETS)).Select
    Application.ScreenUpdating = False
    For Each c In Range("C15:R15")
    c.EntireColumn.Hidden = (c.Value = 0)
    Next c
    Application.ScreenUpdating = True

    End Sub


    Now the part I have highlighted in bold works fine and hides colomns based on their values in cell 15.. its just the process only gets applied to the first sheet in the array (rather then all 15).

    Any ideas how to apply this to all the sheets in the array?

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Hiding particular columns on multiple sheets

    Sheets(Array(ABOUT 15 SHEETS)).Select

    If you want to loop throgh 15 sheets in array, you need to lis the sheets in array.

    Please Login or Register  to view this content.
    Or
    Please Login or Register  to view this content.
    Last edited by AB33; 11-29-2012 at 12:48 PM.

  3. #3
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Hiding particular columns on multiple sheets

    Hi, ge3kspeak,

    get the worksheet to work for the range
    Please Login or Register  to view this content.
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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