+ Reply to Thread
Results 1 to 9 of 9

Hide Row if Value in two cells is zero

  1. #1
    Registered User
    Join Date
    10-21-2015
    Location
    New York
    MS-Off Ver
    MS Office 2013
    Posts
    95

    Hide Row if Value in two cells is zero

    Hi Guys,

    Please help with this VBA code.

    I have values in Columns C & D - cells 20 to 40

    I need to check if both values in C20 and D20; C21 and D21; C22 and D22 etc.., are zero, then hide the rows (current row that contain zero and other rows up to row 40).

    I have found similar code on the forum, but this checks only one cell. Please help guys! Thanks!


    Sub HideRows()
    Application.ScreenUpdating = False
    Application.Calculation = xlManual

    For Each c In Range("C20:C40")
    If c.Value = 0 Then Rows(c.Row).Hidden = True
    Next

    Application.Calculation = xlAutomatic
    Application.ScreenUpdating = True
    End Sub

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,447

    Re: Hide Row if Value in two cells is zero

    Please Login or Register  to view this content.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Hide Row if Value in two cells is zero

    Try

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    10-21-2015
    Location
    New York
    MS-Off Ver
    MS Office 2013
    Posts
    95

    Re: Hide Row if Value in two cells is zero

    Thanks guys!! Works great!

  5. #5
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Hide Row if Value in two cells is zero

    You are welcome!

    Thanks for feedback and rep

    Alf

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,447

    Re: Hide Row if Value in two cells is zero

    Ditto. You're welcome. Thanks for the rep.

  7. #7
    Registered User
    Join Date
    02-09-2009
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Hide Row if Value in two cells is zero

    HI I have the same issue

    but I cant see the code you have got

    I want to hide the row on cell range G29:G245 and Cell range I29:I245

    if the value on both G29 and I29 or G30 and I30 are zero or give an error

    and after it has done that sheet it coninues to the next sheet

    the code I have so far is

    Sub HideRows()
    Dim cell As Range
    For Each cell In Range("G29:G245")
    If Not IsEmpty(cell) Then
    If cell.Value = 0 Then
    cell.EntireRow.Hidden = True
    End If
    Next
    End Sub


    Please please help

  8. #8
    Registered User
    Join Date
    02-09-2009
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Hide Row if Value in two cells is zero

    HI I have the same issue

    but I cant see the code you have got

    I want to hide the row on cell range G29:G245 and Cell range I29:I245

    if the value on both G29 and I29 or G30 and I30 are zero or give an error

    and after it has done that sheet it coninues to the next sheet

    the code I have so far is

    Sub HideRows()
    Dim cell As Range
    For Each cell In Range("G29:G245")
    If Not IsEmpty(cell) Then
    If cell.Value = 0 Then
    cell.EntireRow.Hidden = True
    End If
    Next
    End Sub


    Please please help

  9. #9
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,447

    Re: Hide Row if Value in two cells is zero

    Hello, and welcome to the forum.

    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.

+ 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. Macro to hide cells with duplicate week number cells
    By Jehanim009 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-25-2015, 11:23 AM
  2. HIDE ZEROS IN CHART - Hide rows of cells that equals zero
    By sweedey in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-09-2011, 08:18 PM
  3. Macro to format cells, adjust column widths, hide cells
    By amsolmyers in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-07-2010, 04:44 PM
  4. Replies: 12
    Last Post: 04-20-2010, 02:22 PM
  5. Drop down cells/hide cells
    By Miglia in forum Excel General
    Replies: 0
    Last Post: 06-10-2009, 05:34 PM
  6. Replies: 0
    Last Post: 08-15-2006, 01:25 PM
  7. Hide cells and ranges of cells
    By PeterG in forum Excel General
    Replies: 1
    Last Post: 04-18-2005, 12:31 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