View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
JP[_3_] JP[_3_] is offline
external usenet poster
 
Posts: 168
Default Speed Up this macro?

Sorry that should be

Sub HideRows()
Dim HideRows As Range

ActiveSheet.Range("A1:A10").AutoFilter Field:=1, Criteria1:="=0",
VisibleDropDown:=False

Set HideRows = Range("A2:A10").SpecialCells(xlCellTypeVisible)
ActiveSheet.AutoFilterMode = False
HideRows.EntireRow.Hidden = True
End Sub


Otherwise it hides the header row.

HTH,
JP



On Nov 2, 6:44 pm, JP wrote:
Let's say your data is A2:A10, with a header in A1.

Sub HideRows()
Dim HideRows As Range

ActiveSheet.Range("A1:A10").AutoFilter Field:=1, Criteria1:="=0",
VisibleDropDown:=False

Set HideRows = Range("A1:A10").SpecialCells(xlCellTypeVisible)
ActiveSheet.AutoFilterMode = False
HideRows.EntireRow.Hidden = True
End Sub

HTH,
JP

On Nov 2, 6:09 pm, Joe2007 wrote:



I am using Excel as a quoting system. This Macro hides rows that do not have
quantities in them, but they have to have a zero value in them, not just
blank. It worked pretty fast until I added about a dozen simple macros to
simply hide rows and columns, those macros were not dependent on any data,
simply just highlighted the rows and columns and hid them.


After adding these "simple" macros, the original macro to hide un-used
products with no quantities went EXTREMELY slow on me. All of the command
buttons, I assigned the "simple" macros to blink when I run this most
important macro. The code is below:


Private Sub CommandButton5_Click()


Dim cell As Range, rng As Range
Cells.Rows.Hidden = False
On Error Resume Next
Set rng = Columns(2).SpecialCells(xlConstants, xlNumbers)
On Error GoTo 0
For Each cell In rng
If cell.Value = 0 Then
cell.EntireRow.Hidden = True
End If
Next
End Sub- Hide quoted text -


- Show quoted text -