+ Reply to Thread
Results 1 to 5 of 5

Macro working on incorrect sheet - hiding rows

Hybrid View

  1. #1
    Registered User
    Join Date
    07-07-2015
    Location
    Brisbane
    MS-Off Ver
    2010
    Posts
    8

    Macro working on incorrect sheet - hiding rows

    Hi,

    Trying to make this applicable to hiding rows on a sheet call "Manage & Gov" depending on Level 1, 2 or 3 being entered on a sheet called "Rating" in cell D4. So far whenever level 1, level 2 or level 3 is entered it's hiding rows in the sheet "Rating" rather than "Manage & Gov", any help would be appreciated!


    Private Sub Worksheet_Change(ByVal Target As Range)
        If Target.Address = "$D$4" Then
            Rows("4:11").Hidden = False
            Select Case Target.Value
                Case "Level 1": Sheets("Manage & Gov").Select Rows("6:11").Hidden = True
                Case "Level 2": Sheets("Manage & Gov").Select Rows("4:5")("8:11").Hidden = True
                Case "Level 3": Sheets("Manage & Gov").Select Rows("4:7").Hidden = True
            End Select
        End If
    End Sub
    Last edited by Cchoma; 07-07-2015 at 02:49 AM. Reason: code tag added

  2. #2
    Registered User
    Join Date
    07-07-2015
    Location
    Brisbane
    MS-Off Ver
    2010
    Posts
    8

    Re: Macro working on incorrect sheet - hiding rows

    Private Sub Worksheet_Change(ByVal Target As Range)
        If Target.Address = "$D$4" Then
            Rows("4:11").Hidden = False
    Sheets("Manage & Gov").Select
            Select Case Target.Value
                Case "Level 1": Rows("6:11").Hidden = True
                Case "Level 2": Rows("4:5" "8:11").Hidden = True
                Case "Level 3": Rows("4:7").Hidden = True
            End Select
        End If
    End Sub

    This was a slight variation I tried which also didn't work in the correct worksheet!
    Last edited by Cchoma; 07-07-2015 at 02:50 AM. Reason: code tag added

  3. #3
    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: Macro working on incorrect sheet - hiding rows

    Hi, Cchoma,

    please add code-tags to your procedures as requested in Forum Rule #1.

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$D$4" Then
      Sheets("Manage & Gov").Select
      Rows("4:11").Hidden = False
      Select Case Target.Value
        Case "Level 1": Rows("6:11").Hidden = True
        Case "Level 2": Range("8:10,14:17").EntireRow.Hidden = True
        Case "Level 3": Rows("4:7").Hidden = True
      End Select
    End If
    End Sub
    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

  4. #4
    Registered User
    Join Date
    07-07-2015
    Location
    Brisbane
    MS-Off Ver
    2010
    Posts
    8

    Re: Macro working on incorrect sheet - hiding rows

    Thanks!

    I tried your code and it still seems to only be hiding row's on the "Rating" spreadsheet rather than "Manage & Gov" - would you happen to have any other recommendations?

  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: Macro working on incorrect sheet - hiding rows

    Hi, Cchoma,

    please try this code:
    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$D$4" Then
      With Sheets("Manage & Gov")
        .Rows("4:11").Hidden = False
        Select Case Target.Value
          Case "Level 1"
            .Rows("6:11").Hidden = True
          Case "Level 2"
            .Range("8:10,14:17").EntireRow.Hidden = True
          Case "Level 3"
            .Rows("4:7").Hidden = True
        End Select
      End With
    End If
    End Sub
    Ciao,
    Holger

+ 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] Macro to use array to copy all rows to a new sheet if a cell is not blank not working
    By capson in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-05-2014, 01:13 AM
  2. [SOLVED] Macro for hiding rows before print not working
    By gocolonel77 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-28-2013, 11:05 PM
  3. [SOLVED] Macro for hiding rows not working
    By sunilwadhwa in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-25-2012, 04:31 PM
  4. Print Macro not working...hiding extra fields
    By LarryC in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-30-2008, 08:21 AM
  5. Hiding blank rows on a different sheet
    By yzer19 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-06-2008, 09:22 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