Results 1 to 2 of 2

Enable/Disable vba code

Threaded View

  1. #1
    Registered User
    Join Date
    03-06-2015
    Location
    Rotterdam, The Netherlands
    MS-Off Ver
    2013
    Posts
    22

    Thumbs up Enable/Disable vba code

    I use the following code to hide rows which contain a specific value in a cell.
    In the code below the row will be hidden when the value 1 is placed in any row in column E.

    This is exactly what I need, although I want to have the option to hide and unhide the rows.
    For example when entering a specific value in another cell like: in A1 the word hide or unhide to hide or show all rows.

    How do I extend the script below to achieve this ?

    Private Sub Worksheet_Calculate()
     Dim LastRow As Long, c As Range
     Application.EnableEvents = False
     LastRow = Cells(Cells.Rows.Count, "E").End(xlUp).Row
     On Error Resume Next
     For Each c In Range("E1:E" & LastRow)
        If c.Value = 1 Then
             c.EntireRow.Hidden = True
         ElseIf c.Value = 2 Then
             c.EntireRow.Hidden = False
         End If
     Next
     On Error GoTo 0
     Application.EnableEvents = True
     End Sub
    Last edited by henk400; 04-02-2015 at 08:34 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Code to disable and enable indentations
    By kosherboy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-14-2014, 01:38 PM
  2. Create A Button In Document To Disable/Enable A Specific Line of Code
    By BLK306 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 02-05-2014, 02:12 PM
  3. Enable/disable copy paste (disable part not working)
    By timtim89 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-08-2012, 07:23 PM
  4. Enable and disable
    By rajeev.raj in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-10-2010, 02:50 AM
  5. Enable / Disable CD-ROM thru VB
    By Lochdanon in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-02-2009, 10:43 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