Results 1 to 5 of 5

Need code to hide specific rows based on different cell value

Threaded View

  1. #1
    Registered User
    Join Date
    10-07-2016
    Location
    Lansing, MI
    MS-Off Ver
    2013
    Posts
    2

    Need code to hide specific rows based on different cell value

    Hi all- I don't know VB but need to accomplish hiding different ranges of rows in my spreadsheet based on the value of a field. The field options for cell f9 are 1-4. If '1' is entered in f9, then I have a range of rows below f9 to hide that don't apply. The same is true for 2 and 3. If 4 is entered, then I want all the rows to show. By searching the internet, I pieced together the following code but it doesn't work. Can you help me fix it. Thanks.

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Range("$f$9").Value = "1" Then
        Rows("56:201").EntireRow.Hidden = True
      ElseIf Range("$f$9").Value = "2" Then
        Rows("104:201").EntireRow.Hidden = True
      ElseIf Range("$f$9").Value = "3" Then
        Rows("153:201").EntireRow.Hidden = True
      ElseIf Range("$f$9").Value = "4" Then
        Rows("56:201").EntireRow.Hidden = False
    End If
    End Sub
    Last edited by majzeln; 11-04-2016 at 01:42 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Need to tweak code...Hide Rows Based on Cell Value
    By kmlloyd in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-21-2015, 11:05 AM
  2. [SOLVED] Hide rows based on cell value - VBA code
    By phbryan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-21-2015, 12:38 PM
  3. To hide/unhide rows based on specific value in a cell.
    By @jerry in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-28-2014, 11:56 AM
  4. [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
  5. Looking for a VBA code to hide rows based on a single cell value
    By Dial1 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-30-2013, 07:04 PM
  6. Show/Hide Specific set of Rows based on Criteria in one cell
    By mrgillus in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-11-2010, 01:26 PM
  7. Modify code to hide rows based on the contents in a cell.
    By dcgrove in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-18-2009, 09:07 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