+ Reply to Thread
Results 1 to 4 of 4

Hide Rows based on Cell Value

  1. #1
    Registered User
    Join Date
    11-25-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    61

    Hide Rows based on Cell Value

    Hi All,
    I'm using the following code to hide a row based on cell value in that row. The code works fine but I'd like to not use this repeat code for lines 19 through 58. I know that if, say for example, line 21 is <0 then the rest of the lines to 58 will be <0 as well and will need to be hidden. Is there a simple if-then-next type of check I could use to shorten the amount of code I would need to put in the way I currently show it? Thanks for the help!

    Please Login or Register  to view this content.

  2. #2
    Valued Forum Contributor
    Join Date
    01-19-2012
    Location
    Barrington, IL
    MS-Off Ver
    Excel 2007/2010
    Posts
    1,211

    Re: Hide Rows based on Cell Value

    I'm not great at VBA, still learning, and don't know the exact syntax for this suggestion, however I would imagine you could use a for...next loop to go through the cells one by one

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    11-25-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    61

    Re: Hide Rows based on Cell Value

    Thanks Speshul,
    I've moved to a different approach with the code below but am getting a syntax error. Do you have any thoughts as to why? I'm trying to set the row to start on as maxarray. The error pops up in this line: Sheets("Seismic Data H1").Rows(MaxArray&":58").Select

    Please Login or Register  to view this content.

  4. #4
    Valued Forum Contributor
    Join Date
    01-19-2012
    Location
    Barrington, IL
    MS-Off Ver
    Excel 2007/2010
    Posts
    1,211

    Re: Hide Rows based on Cell Value

    I think I got it; + works in VBA like & works in excel, I guess?

    I added an error handler since you are using a cell reference. Optional, but if it's possible that D49 can be anything other than a number I would recommend some sort or error handler.

    Please Login or Register  to view this content.
    Last edited by Speshul; 06-26-2014 at 12:01 PM.

+ 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. Hide Rows based on cell value
    By mjg060468 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-07-2014, 12:28 PM
  2. [SOLVED] First unhide all rows - then hide rows based on specific cell value for a range of cells
    By robbiekh in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-22-2013, 05:46 PM
  3. Hide rows based on a value in cell A1
    By Torpedojager in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-20-2008, 08:14 AM
  4. [SOLVED] hide rows based on cell value
    By dummster in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 02-15-2006, 07:40 PM
  5. [SOLVED] hide rows based on value in cell
    By dummster in forum Excel General
    Replies: 0
    Last Post: 02-15-2006, 11:30 AM

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