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

Hi, Bob. I get an error on your solution on this section

___________cell.Hidden = cell = 0______________

Private Sub CommandButton5_Click()
Dim cell As Range, rng As Range
With Application
.ScreenUpdating = False
.Calculation = xlCalculationManual
End With
Cells.Rows.Hidden = False
On Error Resume Next
Set rng = Columns(2).SpecialCells(xlConstants, xlNumbers)
On Error GoTo 0
For Each cell In rng
cell.Hidden = cell = 0
Next
With Application
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With
End Sub

"Bob Phillips" wrote:

See if this is any better


Private Sub CommandButton5_Click()
Dim cell As Range, rng As Range
With Application
.ScreenUpdating = False
.Calculation = xlCalculationManual
End With
Cells.Rows.Hidden = False
On Error Resume Next
Set rng = Columns(2).SpecialCells(xlConstants, xlNumbers)
On Error GoTo 0
For Each cell In rng
cell.Hidden = cell = 0
Next
With Application
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With
End Sub



--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Joe2007" wrote in message
...
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