View Single Post
  #13   Report Post  
Posted to microsoft.public.excel.programming
Joe2007 Joe2007 is offline
external usenet poster
 
Posts: 12
Default Speed Up this macro?

Faisal is the Winner! Will this work to speed up my other macros too?

Thanks everyone!

"Faisal..." wrote:

Try add this at the begining:
application.screenupdating=false

and this at the end
application.screenupdating=true



"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