centprop
New Member
- Joined
- Oct 14, 2010
- Messages
- 15
Hi,
I have a clever workbook that creates reports for me. I didn't design this book, and am not all that experienced with VBA.
When it creates these report it hides empty rows to tidy the print layout.
I wanted to create a similar report to an already existing layout, adding an extra couple of columns. So, I copied the sheet with the report I want to modify, and added a couple of new columns and got the data going into the columns perfectly.
When you update the sheets, macros unhide all the previously hidden rows, populates the data, then hides unused rows again. In my new sheet, it unhides the previously hidden rows, but does not hide them again after populating the report with data.
If anyone can help me see what is going on I would be very grateful.
Code refferring to the original sheet that I am copying (called VacHoldingOSRR) looks like this:
I duplicated the code, renamed the macros, and made changes to the names of the named ranges so that they would match the new named ranges in the new sheet. So now the amended code for the new sheet looks like this:
It almost works as expected, with one exception. It no longer hides the unused rows.
Can anyone see why and give me some help to fix it please?
Thanks in advance
Chris
I have a clever workbook that creates reports for me. I didn't design this book, and am not all that experienced with VBA.
When it creates these report it hides empty rows to tidy the print layout.
I wanted to create a similar report to an already existing layout, adding an extra couple of columns. So, I copied the sheet with the report I want to modify, and added a couple of new columns and got the data going into the columns perfectly.
When you update the sheets, macros unhide all the previously hidden rows, populates the data, then hides unused rows again. In my new sheet, it unhides the previously hidden rows, but does not hide them again after populating the report with data.
If anyone can help me see what is going on I would be very grateful.
Code refferring to the original sheet that I am copying (called VacHoldingOSRR) looks like this:
Code:
Sub PortfolioUndatedGaps()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
PortfolioUndatedGapsOpen
PortfolioUndatedGapsClose
Application.Calculation = xlCalculation
Automatic Application.ScreenUpdating = True
End Sub
Code:
Sub PortfolioUndatedGapsOpen()
Application.ScreenUpdating = False
Sheets("VacHoldingOSRR").Activate
Range("UndatedEventCount").Offset(3, 1).Select
Range(ActiveCell, ActiveCell.Offset(100, 0)).Select
Selection.Rows.Hidden = False
Range("A1").Select
End Sub
Code:
Sub PortfolioUndatedGapsClose()
Dim OffsetClose As Integer
Application.ScreenUpdating = False
OffsetClose = Range("UndatedEventCount").Value
Range("UndatedEventCount").Offset(4, 1).Select
If OffsetClose <> 0 Then
ActiveCell.Offset(OffsetClose - 1, 0).Select
End If
Range(ActiveCell, ActiveCell.Offset(100 - OffsetClose - 1, 0)).Select
Selection.Rows.Hidden = True
Range("A1").Select
End Sub
Code:
Sub PortfolioUndatedGaps2()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
PortfolioUndatedGapsOpen2
PortfolioUndatedGapsClose2
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub
Code:
Sub PortfolioUndatedGapsOpen2()
Application.ScreenUpdating = False
Sheets("VacDocNeg").Activate
Range("UndatedEventCountvdn").Offset(3, 1).Select
Range(ActiveCell, ActiveCell.Offset(100, 0)).Select
Selection.Rows.Hidden = False
Range("A1").Select
End Sub
Code:
Sub PortfolioUndatedGapsClose2()
Dim OffsetClose As Integer
Application.ScreenUpdating = False
OffsetClose = Range("UndatedEventCountvdn").Value
Range("UndatedEventCountvdn").Offset(4, 1).Select
If OffsetClose2 <> 0 Then
ActiveCell.Offset(OffsetClose - 1, 0).Select
End If
Range(ActiveCell, ActiveCell.Offset(100 - OffsetClose - 1, 0)).Select
Selection.Rows.Hidden = True
Range("A1").Select
End Sub
Can anyone see why and give me some help to fix it please?
Thanks in advance
Chris