Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default Macro to Hide blank rows

Hi ,

I have the following code wich hides lines in an income statement if active
cell is equal to "Hide". "Hide" is displayed when a divisional total =0.
Each division is shown on a separate page.

Sub Hide_Blanks()

Range("AU14").Select

' Test contents of active cell; if active cell is "end"
Do Until ActiveCell = "end"

ActiveCell.Select
If ActiveCell = "Hide" Then Call hideblanks

' Step down 1 row to the next cell.
ActiveCell.Offset(1, 0).Select

' Return to top of loop.
Loop

Range("a8").Select

End Sub
Sub hideblanks()

ActiveCell.Select
ActiveCell.Offset(1, 0).Select
ActiveCell.PageBreak = False
ActiveCell.Offset(-1, 0).Select
Range(Selection, Selection.End(xlUp)).Select
Selection.EntireRow.Hidden = True
Selection.End(xlDown).Select
ActiveCell.Offset(-1, 0).Select
End Sub


For some reason it hides the rows with data but when I come tp print the
spreadsheet the page still prints off. Tha page is not completely hidden.

I hope I am making sense.

Thanks,





  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 471
Default Macro to Hide blank rows

I am not sure I was following your example. But if your printing is
automated too, perhaps you should share that code because it sounds to me
like you're printing basically a blank page and you wish to skip that page,
right? If that is the case, then your printing code should evalute to see if
there are non-hidden lines and if not, then skip the print routine. HTH

"manfareed" wrote:

Hi ,

I have the following code wich hides lines in an income statement if active
cell is equal to "Hide". "Hide" is displayed when a divisional total =0.
Each division is shown on a separate page.

Sub Hide_Blanks()

Range("AU14").Select

' Test contents of active cell; if active cell is "end"
Do Until ActiveCell = "end"

ActiveCell.Select
If ActiveCell = "Hide" Then Call hideblanks

' Step down 1 row to the next cell.
ActiveCell.Offset(1, 0).Select

' Return to top of loop.
Loop

Range("a8").Select

End Sub
Sub hideblanks()

ActiveCell.Select
ActiveCell.Offset(1, 0).Select
ActiveCell.PageBreak = False
ActiveCell.Offset(-1, 0).Select
Range(Selection, Selection.End(xlUp)).Select
Selection.EntireRow.Hidden = True
Selection.End(xlDown).Select
ActiveCell.Offset(-1, 0).Select
End Sub


For some reason it hides the rows with data but when I come tp print the
spreadsheet the page still prints off. Tha page is not completely hidden.

I hope I am making sense.

Thanks,





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default Macro to Hide blank rows

Hi,

Thanks for your reply. You are right about it printing a blank page. But
there is no print macro. Each division is split via a horizontal page break.

Thanks,


"Mike H." wrote:

I am not sure I was following your example. But if your printing is
automated too, perhaps you should share that code because it sounds to me
like you're printing basically a blank page and you wish to skip that page,
right? If that is the case, then your printing code should evalute to see if
there are non-hidden lines and if not, then skip the print routine. HTH

"manfareed" wrote:

Hi ,

I have the following code wich hides lines in an income statement if active
cell is equal to "Hide". "Hide" is displayed when a divisional total =0.
Each division is shown on a separate page.

Sub Hide_Blanks()

Range("AU14").Select

' Test contents of active cell; if active cell is "end"
Do Until ActiveCell = "end"

ActiveCell.Select
If ActiveCell = "Hide" Then Call hideblanks

' Step down 1 row to the next cell.
ActiveCell.Offset(1, 0).Select

' Return to top of loop.
Loop

Range("a8").Select

End Sub
Sub hideblanks()

ActiveCell.Select
ActiveCell.Offset(1, 0).Select
ActiveCell.PageBreak = False
ActiveCell.Offset(-1, 0).Select
Range(Selection, Selection.End(xlUp)).Select
Selection.EntireRow.Hidden = True
Selection.End(xlDown).Select
ActiveCell.Offset(-1, 0).Select
End Sub


For some reason it hides the rows with data but when I come tp print the
spreadsheet the page still prints off. Tha page is not completely hidden.

I hope I am making sense.

Thanks,





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 471
Default Macro to Hide blank rows

I am not sure what you'd have to do, but if it were me, I'd create a print
macro and then create different Custom Views (See help for how to do this).
Then in the macro evaluate each division to see if there is unhidden lines or
not. If so, switch to that division's custom view and then print the report.
Otherwise, you'd just skip it. Here is a sample:

Sub PrintOutReports
Dim Div1Visible as double
Dim Div2Visible as double
'You'll need code here to set values to Div?Visible
If Div1Visible0 then
ActiveWorkbook.CustomViews("Division1").Show
ActiveWindow.SelectedSheets.PrintPreview
end if
if Div2Visible0 then
ActiveWorkbook.CustomViews("Division2").Show
ActiveWindow.SelectedSheets.PrintPreview
end if

End sub

You can change the printpreview to print outs as needed. HTH


"manfareed" wrote:

Hi,

Thanks for your reply. You are right about it printing a blank page. But
there is no print macro. Each division is split via a horizontal page break.

Thanks,


"Mike H." wrote:

I am not sure I was following your example. But if your printing is
automated too, perhaps you should share that code because it sounds to me
like you're printing basically a blank page and you wish to skip that page,
right? If that is the case, then your printing code should evalute to see if
there are non-hidden lines and if not, then skip the print routine. HTH

"manfareed" wrote:

Hi ,

I have the following code wich hides lines in an income statement if active
cell is equal to "Hide". "Hide" is displayed when a divisional total =0.
Each division is shown on a separate page.

Sub Hide_Blanks()

Range("AU14").Select

' Test contents of active cell; if active cell is "end"
Do Until ActiveCell = "end"

ActiveCell.Select
If ActiveCell = "Hide" Then Call hideblanks

' Step down 1 row to the next cell.
ActiveCell.Offset(1, 0).Select

' Return to top of loop.
Loop

Range("a8").Select

End Sub
Sub hideblanks()

ActiveCell.Select
ActiveCell.Offset(1, 0).Select
ActiveCell.PageBreak = False
ActiveCell.Offset(-1, 0).Select
Range(Selection, Selection.End(xlUp)).Select
Selection.EntireRow.Hidden = True
Selection.End(xlDown).Select
ActiveCell.Offset(-1, 0).Select
End Sub


For some reason it hides the rows with data but when I come tp print the
spreadsheet the page still prints off. Tha page is not completely hidden.

I hope I am making sense.

Thanks,





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default Macro to Hide blank rows

Hi Mike,

Thanks for your help. I'll follow your advice.

Regards,

Manir

"Mike H." wrote:

I am not sure what you'd have to do, but if it were me, I'd create a print
macro and then create different Custom Views (See help for how to do this).
Then in the macro evaluate each division to see if there is unhidden lines or
not. If so, switch to that division's custom view and then print the report.
Otherwise, you'd just skip it. Here is a sample:

Sub PrintOutReports
Dim Div1Visible as double
Dim Div2Visible as double
'You'll need code here to set values to Div?Visible
If Div1Visible0 then
ActiveWorkbook.CustomViews("Division1").Show
ActiveWindow.SelectedSheets.PrintPreview
end if
if Div2Visible0 then
ActiveWorkbook.CustomViews("Division2").Show
ActiveWindow.SelectedSheets.PrintPreview
end if

End sub

You can change the printpreview to print outs as needed. HTH


"manfareed" wrote:

Hi,

Thanks for your reply. You are right about it printing a blank page. But
there is no print macro. Each division is split via a horizontal page break.

Thanks,


"Mike H." wrote:

I am not sure I was following your example. But if your printing is
automated too, perhaps you should share that code because it sounds to me
like you're printing basically a blank page and you wish to skip that page,
right? If that is the case, then your printing code should evalute to see if
there are non-hidden lines and if not, then skip the print routine. HTH

"manfareed" wrote:

Hi ,

I have the following code wich hides lines in an income statement if active
cell is equal to "Hide". "Hide" is displayed when a divisional total =0.
Each division is shown on a separate page.

Sub Hide_Blanks()

Range("AU14").Select

' Test contents of active cell; if active cell is "end"
Do Until ActiveCell = "end"

ActiveCell.Select
If ActiveCell = "Hide" Then Call hideblanks

' Step down 1 row to the next cell.
ActiveCell.Offset(1, 0).Select

' Return to top of loop.
Loop

Range("a8").Select

End Sub
Sub hideblanks()

ActiveCell.Select
ActiveCell.Offset(1, 0).Select
ActiveCell.PageBreak = False
ActiveCell.Offset(-1, 0).Select
Range(Selection, Selection.End(xlUp)).Select
Selection.EntireRow.Hidden = True
Selection.End(xlDown).Select
ActiveCell.Offset(-1, 0).Select
End Sub


For some reason it hides the rows with data but when I come tp print the
spreadsheet the page still prints off. Tha page is not completely hidden.

I hope I am making sense.

Thanks,





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
Macro to HIDE blank rows JForsyth Excel Worksheet Functions 6 June 5th 09 04:51 PM
How to hide rows, but not blank rows used for formatting hko78 Excel Programming 10 May 14th 08 07:58 PM
Macro hide rows with blank data in cells [email protected] Excel Programming 6 August 22nd 07 09:10 PM
Macro to hide blank rows Alan Smith Excel Programming 3 February 23rd 07 04:35 PM
macro to hide rows if cell is blank Shooter Excel Worksheet Functions 3 September 28th 05 10:55 PM


All times are GMT +1. The time now is 09:48 AM.

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

About Us

"It's about Microsoft Excel"