Thread
:
Getting compile error on WorksheetFuntion.Sum line
View Single Post
#
5
Posted to microsoft.public.excel.programming
Don Guillett[_2_]
external usenet poster
Posts: 1,522
Getting compile error on WorksheetFuntion.Sum line
Try it this way without selections from anywhere in the workbook.
Sub HideRowsSAS()
Set rng = Range("MELLandLabor")
If Application.Sum(rng.Columns(6)) = 0 Then
rng.Rows.Hidden = True
Else
For n = 1 To rng.Rows.Count
If rng.Cells(n, 6) = "" Or rng.Cells(n, 6) = 0 _
Then rng.Rows(n).Hidden = True
Next n
End If
End Sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software
"froggygremblin" wrote in message
...
I am trying to test if the sum of column 6 in a named range is 0 and if it
is I hide the whole range, if its not I hide only teh lines that are 0 or
blank. I get a complie error on the If WorksheetFuntion.Sum line. What
is
the correct syntax?
Application.Goto reference:="MELLandLabor"
Set rng = Range("MELLandLabor")
If WorksheetFunction.Sum(rng.Cells(1, 6), rng.cells(rng.Rows.Count, 6)
=
0 then
Selection.EntireRow.Hidden = True
Else
For n = 1 To rng.Rows.Count
rng.Cells(n, 6).Select
If rng.Cells(n, 6) = "" Or rng.Cells(n, 6) = 0 Then
rng.Cells(n, 6).EntireRow.Hidden = True
End If
Next n
End If
Thanks for your Help.
Rick
Reply With Quote
Don Guillett[_2_]
View Public Profile
Find all posts by Don Guillett[_2_]