+ Reply to Thread
Results 1 to 5 of 5

Macro for hide rows with the cell value "aaa"

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    07-07-2014
    Location
    Göteborg
    MS-Off Ver
    2010
    Posts
    130

    Macro for hide rows with the cell value "aaa"

    Hi!
    I need a little bit help with a macro. In column A i got several projects and if the cell value is "aaa", then I want to hide the row. The projects will always be in row 4 to 703. I have a macro thats working but is super slow so maybe you can help with some smarter way to solve this. My macro right now is:

    Sub ActiveProjectandSections()
    Application.ScreenUpdating = False

    Set rng = Range("A4:A703")
    For Each cell In rng
    If cell.Value = "aaa" Then
    cell.EntireRow.Hidden = True
    End If
    Next cell
    Application.ScreenUpdating = True

    Sincerely,
    Niclas

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Macro for hide rows with the cell value "aaa"

    You could autofilter out the "aaa". That will probably be one of the fastest ways.

    Sub ActiveProjectandSections()
    Dim ws As Worksheet:    Set ws = ActiveSheet
    
    Application.ScreenUpdating = False
    
    With ws
        .AutoFilterMode = False
        .Range("A4:A703").AutoFilter 1, "<>aaa"
    End With
        
    Application.ScreenUpdating = True
    
    End Sub

  3. #3
    Forum Contributor amartinez988's Avatar
    Join Date
    05-04-2015
    Location
    Miami
    MS-Off Ver
    Office 2010
    Posts
    183

    Re: Macro for hide rows with the cell value "aaa"

    Check to see if this one is faster:

    Sub HideRows()
    
        Dim rData As Range
        
        Set rData = Range("B4:B707") ' Use any empty column to work with
        
        rData.Formula = "=IF(A4=""aaa"","""",A4)" ' Put a formula that get you all aaa as blank cells
        rData.Value = rData.Value ' copy the values
        
        rData.SpecialCells(xlCellTypeBlanks).Rows.Hidden = True ' hide cells in blank
        
    End Sub
    Let me know

  4. #4
    Forum Contributor
    Join Date
    07-07-2014
    Location
    Göteborg
    MS-Off Ver
    2010
    Posts
    130

    Re: Macro for hide rows with the cell value "aaa"

    Thank you both! Both of the ideas working and are going very fast! I decided to go on the second idea since I also use outliners and they clash a bit. Thanks anyway!!

  5. #5
    Forum Contributor amartinez988's Avatar
    Join Date
    05-04-2015
    Location
    Miami
    MS-Off Ver
    Office 2010
    Posts
    183

    Re: Macro for hide rows with the cell value "aaa"

    Great!

    Please don't forget to close post as solved and reputation if any of the suggestion worked for you in any way.

    Good luck!

+ 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] Multiple Worksheet Change events??? "macro" needed to hide/unhide rows multiple instances
    By dgibney in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-02-2014, 03:40 PM
  2. [SOLVED] Click "-" or "+" to hide and unhide rows
    By Rocky2013 in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 11-09-2013, 08:03 AM
  3. Replies: 1
    Last Post: 09-21-2013, 03:18 AM
  4. [SOLVED] Is it possible to a macro go row by row and hide (or delete) and rows where column 1 is ""
    By CDNcameron in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-20-2013, 02:14 PM
  5. Create Macro if any cell under "QUANTITY" Column = 0, then Hide, Multiple Worksheets
    By Spodzemny in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-19-2013, 04:15 PM

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