#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 46
Default Hiding rows

I have the following formula in cell A5 and throughout the sheet
=if(Sum(A1:A4)0,Sum(A1:A4),"") If the answer returns "" (blank) I want my
macro to hide the row using
"Range("MyRange").Columns(5).SpecialCells(xlBlanks ).EntireRow.Hidden = True".
However the code sees the formula and says it is not blank. How can I get
around that?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Hiding rows

Hi pkeegs

You must loop through the range
Try this example

My EasyFilter add-in have also this option
http://www.rondebruin.nl/easyfilter.htm

Sub Example3()
Dim Lrow As Long
Dim CalcMode As Long
Dim ViewMode As Long
Dim StartRow As Long
Dim EndRow As Long

With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With

ViewMode = ActiveWindow.View
ActiveWindow.View = xlNormalView

With ActiveSheet
.DisplayPageBreaks = False
StartRow = 5
EndRow = .Cells(.Rows.Count, "A").End(xlUp).Row

For Lrow = EndRow To StartRow Step -1

If IsError(.Cells(Lrow, "A").Value) Then
'Do nothing, This avoid a error if there is a error in the cell

ElseIf .Cells(Lrow, "A").Value = "" Then .Rows(Lrow).Hidden = True

End If
Next
End With

ActiveWindow.View = ViewMode
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With

End Sub

--
Regards Ron De Bruin
http://www.rondebruin.nl



"pkeegs" wrote in message ...
I have the following formula in cell A5 and throughout the sheet
=if(Sum(A1:A4)0,Sum(A1:A4),"") If the answer returns "" (blank) I want my
macro to hide the row using
"Range("MyRange").Columns(5).SpecialCells(xlBlanks ).EntireRow.Hidden = True".
However the code sees the formula and says it is not blank. How can I get
around that?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 46
Default Hiding rows

Thanks Ron,
I had not thought about a loop and I have ended up using one. I don't have
sufficient knowledge of VBA to understand your language, but simply looping
through the cells with an if statement is giving me the result I require.

"Ron de Bruin" wrote:

Hi pkeegs

You must loop through the range
Try this example

My EasyFilter add-in have also this option
http://www.rondebruin.nl/easyfilter.htm

Sub Example3()
Dim Lrow As Long
Dim CalcMode As Long
Dim ViewMode As Long
Dim StartRow As Long
Dim EndRow As Long

With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With

ViewMode = ActiveWindow.View
ActiveWindow.View = xlNormalView

With ActiveSheet
.DisplayPageBreaks = False
StartRow = 5
EndRow = .Cells(.Rows.Count, "A").End(xlUp).Row

For Lrow = EndRow To StartRow Step -1

If IsError(.Cells(Lrow, "A").Value) Then
'Do nothing, This avoid a error if there is a error in the cell

ElseIf .Cells(Lrow, "A").Value = "" Then .Rows(Lrow).Hidden = True

End If
Next
End With

ActiveWindow.View = ViewMode
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With

End Sub

--
Regards Ron De Bruin
http://www.rondebruin.nl



"pkeegs" wrote in message ...
I have the following formula in cell A5 and throughout the sheet
=if(Sum(A1:A4)0,Sum(A1:A4),"") If the answer returns "" (blank) I want my
macro to hide the row using
"Range("MyRange").Columns(5).SpecialCells(xlBlanks ).EntireRow.Hidden = True".
However the code sees the formula and says it is not blank. How can I get
around that?




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Color alternate rows when after hiding selected rows Monk[_2_] Excel Worksheet Functions 6 June 7th 08 01:36 AM
Hiding Specific Rows Based on Values in Other Rows Chris Excel Worksheet Functions 1 November 2nd 06 08:21 PM
Hiding a button when hiding rows fergusor Excel Discussion (Misc queries) 2 August 10th 06 02:31 PM
hiding Rows and buttons/comboxes, over the rows Ctech[_116_] Excel Programming 1 March 21st 06 12:38 PM
Hiding Rows if the linked rows are blank KG Excel Discussion (Misc queries) 9 May 18th 05 02:32 AM


All times are GMT +1. The time now is 08:52 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"