+ Reply to Thread
Results 1 to 8 of 8

VBA macro that hide and unhide column to respective rows based on first column value

  1. #1
    Registered User
    Join Date
    02-14-2013
    Location
    Belize
    MS-Off Ver
    Excel 2010
    Posts
    5

    VBA macro that hide and unhide column to respective rows based on first column value

    Hi, I am in need of dire assistance. I have an excel sheet that has 5 columns and dynamic range of row.
    Column A has Error Messages that can either start with ED*, O14*, and HL*.
    Columns to be hidden dependent on Column A value is below

    • ED*- only column B and C hidden
      O14*- only column B, C, D hidden
      HL*- only column C and E hidden

    However, I don't want the columns to be hidden just to a that particular cell in Column A, but to that row of that cell.
    I attached a sample excel file.
    sample.xlsx

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: VBA macro that hide and unhide column to respective rows based on first column value

    I could be wrong but I don't think you can hide an individual cell like you could a column or row. You can hide its contents through formatting (ie. setting its format to ";;;"). With that being said I am not sure what you are wanting to accomplish. Do you want to hide you specified columns based on only 1 parameter? Do you just want to make the contents invisible? Please clarify.

  3. #3
    Registered User
    Join Date
    02-14-2013
    Location
    Belize
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: VBA macro that hide and unhide column to respective rows based on first column value

    I want to hide the specified columns to one parameter- the contents of Column A, but instead of the columns being hidden to just the column A cell I want the columns hidden to the row of that cell.

  4. #4
    Registered User
    Join Date
    02-14-2013
    Location
    Belize
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: VBA macro that hide and unhide column to respective rows based on first column value

    See that's my problem; I can hide the columns based on cell value which is fine, but I also need the columns to be hidden to the row of that cell as well. For instance, A2 has ED*; A2 will have only column B and C hidden, but the column B and C hidden would be visible in D2 and E2 and I want it hidden. The hidden of columns should apply to the entire row dependent on cell value in column A.
    Last edited by janine6192; 02-14-2013 at 12:42 PM.

  5. #5
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: VBA macro that hide and unhide column to respective rows based on first column value

    Yeah I believe its all or nothing when hiding columns. You could delete the cells in that row and shift the remaining ones to the left but I don't think you want to do that. What you want to do may not be possible.

  6. #6
    Registered User
    Join Date
    02-14-2013
    Location
    Belize
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: VBA macro that hide and unhide column to respective rows based on first column value

    Hmm. What do you suggest? In actuality there are 50 columns; but dependent on Column A's cell value the user may only need 8 or 10 columns. I don't want the user to input data in the wrong columns. So that's why I was trying to hide some of the columns.

  7. #7
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: VBA macro that hide and unhide column to respective rows based on first column value

    It really depends on the flow of your spreadsheet. In other words what are the procecess the user does. If for example they only enter in new data then I would probably set up a userform to popluate what you need. If they are going back and changing data in already completed row then you could lock certain cells.

  8. #8
    Registered User
    Join Date
    02-14-2013
    Location
    Belize
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: VBA macro that hide and unhide column to respective rows based on first column value

    Thanks, I used the locking of cells. It is perfect. Thanks so much.

+ 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