+ Reply to Thread
Results 1 to 5 of 5

Hide Rows Based on Text in Cell

Hybrid View

jgray Hide Rows Based on Text in... 06-24-2014, 05:02 PM
patel45 Re: Hide Rows Based on Text... 06-25-2014, 12:28 AM
Naveed Raza Re: Hide Rows Based on Text... 06-25-2014, 12:52 AM
patel45 Re: Hide Rows Based on Text... 06-25-2014, 02:01 AM
HaHoBe Re: Hide Rows Based on Text... 06-25-2014, 02:13 AM
  1. #1
    Registered User
    Join Date
    04-30-2010
    Location
    washington dc
    MS-Off Ver
    Excel 2007
    Posts
    51

    Hide Rows Based on Text in Cell

    Hi -

    I'm looking for a macro that will hide specified range of rows depending on the text found in a cell.

    Specifically, in the attached workbook on the "Dashboard Tab", when the formula in cell D3 returns "Year 5", I want the macro to hide rows 5:143. If the formula in cell D3 returns "Year 1", I want it to hide rows 39:179.

    Any help?

    Thanks!Deliverables Tracker_Excel Forum_6-23-2014.xlsm

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Hide Rows Based on Text in Cell

    you attached a protected workbook
    If solved remember to mark Thread as solved

  3. #3
    Valued Forum Contributor Naveed Raza's Avatar
    Join Date
    11-04-2012
    Location
    India, Hyderabad
    MS-Off Ver
    Excel, Access 2007/2010
    Posts
    1,338

    Re: Hide Rows Based on Text in Cell

    try this attached file
    Attached Files Attached Files
    Thanks - Naveed
    -----------------------------
    If the suggestion helps you, then Click * to Add Reputation
    To Attach File: Go Advanced>>Manage Attachments>>Add Files (In Top Right Corner)>>SelectFiles>>.........Locate Your File(s)>>Upload Files>>Done (In Bottom Right)
    1. Use [code] code tags [\code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    2. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

  4. #4
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Hide Rows Based on Text in Cell

    Sub a()
    If Range("D3").Value = "Year 1" Then
      Rows("39:179").Select
      Selection.EntireRow.Hidden = True
    End If
    If Range("D3").Value = "Year 5" Then
      Rows("5:143").Select
      Selection.EntireRow.Hidden = True
    End If
    End Sub
    You can add the others options

  5. #5
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Hide Rows Based on Text in Cell

    Hi, patel45,

    there´s hardly a need to Select a range prior to doing any action on it. More obvious is that you would need to make sure that the entire area is visible prior to hide any rows, maybe add at the beginning
    Range("A5:A178").EntireRow.Hidden = False
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

+ 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. VBA to automatically hide rows based on text
    By melliard5779259 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-23-2014, 08:38 AM
  2. [SOLVED] Macro to Show/Hide Rows Based on Text in Cell
    By HCopeland3 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-01-2014, 03:56 PM
  3. [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
  4. [SOLVED] hide or unhide rows based on text within a drop down list
    By souimet in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-17-2013, 01:32 AM
  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

Tags for this Thread

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