+ Reply to Thread
Results 1 to 11 of 11

Clunky Slow Code, Hides Empty Rows, Takes too long...

Hybrid View

BoSonic Clunky Slow Code, Hides Empty... 12-18-2013, 03:37 PM
Olly Re: Clunky Slow Code, Hides... 12-18-2013, 03:43 PM
Olly Re: Clunky Slow Code, Hides... 12-18-2013, 03:45 PM
BoSonic Re: Clunky Slow Code, Hides... 12-18-2013, 04:34 PM
mehmetcik Re: Clunky Slow Code, Hides... 12-18-2013, 04:54 PM
BoSonic Re: Clunky Slow Code, Hides... 12-18-2013, 05:47 PM
BoSonic Re: Clunky Slow Code, Hides... 12-18-2013, 05:57 PM
mehmetcik Re: Clunky Slow Code, Hides... 12-18-2013, 07:56 PM
BoSonic Re: Clunky Slow Code, Hides... 12-18-2013, 08:56 PM
mehmetcik Re: Clunky Slow Code, Hides... 12-18-2013, 04:52 PM
mehmetcik Re: Clunky Slow Code, Hides... 12-18-2013, 07:41 PM
  1. #1
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Clunky Slow Code, Hides Empty Rows, Takes too long...

    Hi

    All you have to do is to hide the formulas returning blanks I would have thought.


    
    
    Sub UnhideMacro()
    Dim c As Range
    ActiveSheet.UsedRange.SpecialCells(xlCellTypeFormulas, xlNumbers + xlTextValues).Select
    For Each c In Selection
    If c.Value <> "" Then c.EntireRow.Hidden = False
    Next c
    ActiveSheet.UsedRange.SpecialCells(xlCellTypeConstants, xlNumbers + xlTextValues).Select
    Selection.EntireRow.Hidden = False
    End Sub

  2. #2
    Registered User
    Join Date
    11-08-2013
    Location
    Sacramento, California
    MS-Off Ver
    Excel 2010
    Posts
    25

    Re: Clunky Slow Code, Hides Empty Rows, Takes too long...

    Thanks again for your response! Oddly enough, this code works but only if my formulas have the IF(ref="","",ref) convention, but unfortunately, it puts me back in the same position of iterating through many cells and the time it takes to process is about the same as my original code. I'm not sure if you were referring to hiding the formulas (as in protect sheet) or just hiding 0s... I'm also not sure why your first code didn't work but it did with the FOR EACH loop. I even tried defining the ranges.

    I actually did get my array solution to check the IF<>EMPTY condition based on array index but then I run into another issue: using Union to join two non-contiguous ranges. Which is why in the following code I had to dim my array as A:C and then of course in the scope of things I am once again not speeding up the process very much. This has been a difficult one for me.
    Option Explicit
    
    Sub F2HideRows()
    
    Application.ScreenUpdating = False
    
    Dim i As Long
    Dim p As Long
    Dim varray As Variant
    
    varray = Sheets("F2").Range("A21:D39").Value
    
    
    Sheets("F2").Range("F2HideRows").Rows.EntireRow.Hidden = True
    
    
        For i = 1 To UBound(varray, 1)
            For p = 1 To UBound(varray, 2) Step 3
                If varray(i, p) <> Empty Then
                Range("A" & i + 20).EntireRow.Hidden = False
                End If
            Next p
        Next i
    
    
     On Error GoTo 0
    
    Application.ScreenUpdating = True
    
    End Sub

+ 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. VBA that hides rows with 0 takes FOREVER to run
    By Sky188 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-28-2013, 04:04 PM
  2. [SOLVED] Worksheet Macro that hides empty rows does not work
    By Taktiker in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-22-2012, 11:11 AM
  3. Long code takes an age to run
    By E3iron in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-05-2009, 07:38 AM
  4. My Code takes too long to execute
    By coreytroy in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-30-2008, 12:12 AM
  5. macro that hides rows run slow
    By yoav_b in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-15-2007, 11:16 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