+ Reply to Thread
Results 1 to 6 of 6

VBA Auto Hide/unhide row

  1. #1
    Registered User
    Join Date
    09-01-2015
    Location
    ia
    MS-Off Ver
    2007
    Posts
    12

    VBA Auto Hide/unhide row

    I'm building a spreadsheet in which I would like to have some rows auto hide and unhide based on a value in a separate cell and have a two part question.

    For example, if cell A5 = "", then auto hide row 12. Below is the code I've done so far that works in part.

    Question 1. I can get the code to work by manually clearing cell A5. However, I want to go a step further by having a If statement in A5 ,for example, =if(a1="x","x",""). As soon as I add the IF statement to a5, the auto hide/unhide no longer works. Although my target cell A5 is technically blank from visible view, it's like the VBA is seeing the IF statement as not blank or "". Is there a way to make this work if the target cell A5 has an if statement that results in a blank?

    Question 2. How would I go about adding additional unrelated target cells and result rows? Example, if cell A6 = "", then hide row 13.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    365 Version 2409
    Posts
    2,789

    Re: VBA Auto Hide/unhide row

    You are using the worksheet change event. The worksheet change event does not get triggered when the change is the result of a formula.

  3. #3
    Registered User
    Join Date
    09-01-2015
    Location
    ia
    MS-Off Ver
    2007
    Posts
    12

    Re: VBA Auto Hide/unhide row

    I've changed to a worksheet calculate. I was able to get my rows to hide/unhide with one caveat. At the moment, all cells from A4:A15 show an X if A3 has an X. =if(a3="x","x",""). A16 will only show an X if C15 meets a certain condition. If I make that condition true, and in turn make A16 have an X, I can't seem to get the VBA code to unhide it's line. Is it possible that the A16 x doesn't exist until after the code runs, and thus does not unhide the row?


    Please Login or Register  to view this content.

  4. #4
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    365 Version 2409
    Posts
    2,789

    Re: VBA Auto Hide/unhide row

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

  5. #5
    Registered User
    Join Date
    09-01-2015
    Location
    ia
    MS-Off Ver
    2007
    Posts
    12
    Quote Originally Posted by skywriter View Post
    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic
    Maybe I had a bad excel day, but now it's working. I changed my secondary's to an if/and with a reference back to my initial line. Now my secondary's are closing and opening as they should be. I'll dink with it some more over the weekend when I get some spare time to see if all stays well. If I run into issue, I'll create a new sample worksheet to upload for review.

  6. #6
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    365 Version 2409
    Posts
    2,789

    Re: VBA Auto Hide/unhide row

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Auto Hide / UnHide Rows
    By StudioLETA in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-08-2015, 02:50 PM
  2. Auto hide and Unhide worksheet
    By Poh Kai Siang in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-19-2015, 12:04 PM
  3. [SOLVED] Auto hide/unhide row based on row above
    By wjwelch1 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-14-2014, 02:10 PM
  4. [SOLVED] How to auto hide/unhide rows based on value of sum
    By wesleeptheylive in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-27-2013, 04:34 PM
  5. [SOLVED] Auto unhide/hide columns
    By FragaGeddon in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-30-2012, 05:50 PM
  6. Auto Hide or Unhide rows.
    By Michael S in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-19-2009, 06:04 PM
  7. [SOLVED] Auto hide/Unhide columns
    By Vespaguy in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-20-2006, 01:40 PM

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