+ Reply to Thread
Results 1 to 8 of 8

Hide a range based on the vaue in a cell

Hybrid View

JmundleBofA Hide a range based on the... 02-26-2014, 02:51 PM
TMS Re: Hide a range based on the... 02-26-2014, 02:59 PM
JmundleBofA Re: Hide a range based on the... 02-26-2014, 03:12 PM
JmundleBofA Re: Hide a range based on the... 03-17-2014, 07:49 PM
TMS Re: Hide a range based on the... 02-26-2014, 03:18 PM
TMS Re: Hide a range based on the... 03-17-2014, 07:55 PM
JmundleBofA Re: Hide a range based on the... 03-17-2014, 09:22 PM
TMS Re: Hide a range based on the... 03-17-2014, 10:50 PM
  1. #1
    Registered User
    Join Date
    04-24-2013
    Location
    Charlotte NC
    MS-Off Ver
    Excel 2007
    Posts
    31

    Cool Hide a range based on the vaue in a cell

    I am trying to add this to my workbook but I am not able to get it to work properly

    what I would like to do is if cell C21 is Blank/Null then hide row range 23:30


    If Range("c21") = "" Then
    Rows("23:29").EntireRow.Hidden = True
    Else
    Rows("23:29").EntireRow.Hidden = False
    End If

    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
    48,492

    Re: Hide a range based on the vaue in a cell

    Nothing wrong with the code other than, if you want to hide row 30, it doesn't.

    Option Explicit
    
    Sub Test()
    
    If Range("c21") = "" Then
        Rows("23:29").EntireRow.Hidden = True
    Else
        Rows("23:29").EntireRow.Hidden = False
    End If
    
    End Sub

    Regards, TMS
    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
    Registered User
    Join Date
    04-24-2013
    Location
    Charlotte NC
    MS-Off Ver
    Excel 2007
    Posts
    31

    Re: Hide a range based on the vaue in a cell

    Trevor, thank you for your response it is still not working, if I have hidden columns in my workbook would that prevent it from working.
    Last edited by JmundleBofA; 03-17-2014 at 09:23 PM. Reason: spelling eror

  4. #4
    Registered User
    Join Date
    04-24-2013
    Location
    Charlotte NC
    MS-Off Ver
    Excel 2007
    Posts
    31

    Re: Hide a range based on the vaue in a cell

    removed to create a new Thread
    Last edited by JmundleBofA; 03-17-2014 at 09:28 PM.

  5. #5
    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
    48,492

    Re: Hide a range based on the vaue in a cell

    if I have hidden columns in my workbook would that prevent it from working
    No. At least it doesn't for me in a simulation.

    Suggest you post a sample workbook so that the code, and the issue, can be seen in context.

    Regards, TMS

  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
    48,492

    Re: Hide a range based on the vaue in a cell

    @JmundleBofA:

    Five points ...

    1. You never replied to my last post
    2. If the thread was answered/solved you should mark it solved ... and common courtesy suggests you say thank you
    3. New question, new thread
    4. You need to use Code Tags around your code example (although I let it ride last time ... and the Moderators didn't pick it up)
    5. You are more likely to get help if you upload a sample workbook


    Regards, TMS

  7. #7
    Registered User
    Join Date
    04-24-2013
    Location
    Charlotte NC
    MS-Off Ver
    Excel 2007
    Posts
    31

    Re: Hide a range based on the vaue in a cell

    I am sorry, I am new to posting my questions:

    1. I did figure out my issue, i typed something incorrectly.
    2. I will mark as solved, I did not mean to offend.
    3. I will create a new thread.
    4. What is a "Code Tag"

  8. #8
    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
    48,492

    Re: Hide a range based on the vaue in a cell

    Use code tags around code.

    Posting code between [CODE] [/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

+ 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. [SOLVED] How to hide rows based on cell value, row range is dynamic.
    By csh8428 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-03-2012, 02:05 PM
  2. [SOLVED] Hide columns based on cell value - Unable to set hidden range property of Range Class
    By trillium in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-13-2012, 11:13 PM
  3. Hide range of cells based on other cell value?
    By proepert in forum Excel General
    Replies: 1
    Last Post: 11-24-2009, 12:15 PM
  4. Hide "0" vaue data labels
    By genus in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 02-15-2008, 05:27 PM
  5. [SOLVED] Hide or Highlight Row or Range based on changing cell value
    By batman07@gmail.com in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-12-2006, 02:00 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