+ Reply to Thread
Results 1 to 2 of 2

# Hide rows if certain cell is...

  1. #1
    Registered User
    Join Date
    10-15-2014
    Location
    Copenhagen
    MS-Off Ver
    201, 2013, 365
    Posts
    42

    Exclamation # Hide rows if certain cell is...

    Hi

    I worte this VBA code, should be easy but nothing is today :-(
    I want to hide row 35:38, if cell D34 is text "Nej"

    What am I doing wrong ??

    / Kristian


    [CODE]
    Sub HideRows()
    Dim oSheet As Excel.Worksheet
    Set oSheet = ActiveWorkbook.Sheets("Info om virksomheden")
    ActiveSheet.Unprotect "ERV-2017"

    If Target.Address = "$D$34" Then
    If Target.Value = "Nej" Then
    ActiveSheet.Rows("35:38").EntireRow.Hidden = True

    Else

    Set oSheet = ActiveWorkbook.Sheets("Info om virksomheden")
    ActiveSheet.Rows("35:38").EntireRow.Hidden = False

    End If
    End If

    End Sub
    [/ CODE]

  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,440

    Re: # Hide rows if certain cell is...

    Target only exists in some Event handler code. So, you would test the value of cell D34.
    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


+ 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. Hide Rows/Hide Columns Based on Value in Cell
    By brickwall823 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-24-2015, 02:42 PM
  2. Need Toggle Button to hide/unhide rows based on cell value in non concurrent rows
    By The Phoenix in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 07-13-2015, 10:49 AM
  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. Hide Rows with a Value (2 values to hide) then delete visible rows
    By Slea in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 08-19-2013, 06:25 AM
  5. Hide multiple rows below target cell based on a cell value match elsewhere.
    By tapmagoo in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-09-2013, 12:37 PM
  6. Using check boxes to hide and un-hide rows with drop down lists within rows
    By Sparky_Chris in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-24-2012, 07:22 AM
  7. Hide rows by cell value
    By bas_deejay in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-14-2011, 08:31 AM

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