Macro Problems adding to an existsing workbook.

centprop

New Member
Joined
Oct 14, 2010
Messages
15
Hi,

I have a very clever workbook that creates reports for me. I didn't design this book, and am not all that experienced with VBA.

When it creates this report it hides unused lines to create the print layout.

I copied an existing sheet, to amend it to add a couple of new columns. This new sheet I have got to expand the sheet, but cant then hide any blank rows.

Existing code looks like this:
Code:
Sub PortfolioUndatedGaps()

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
PortfolioUndatedGapsOpen
PortfolioUndatedGapsClose
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True

End Sub

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

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

I duplicated the code, and made changes to the names of the named selections so that they would match the new named selections (sorry - I don't know the official term for the named selections - this is what you see in the name manager). So now the amended code for the new sheet looks like this:

Code:
Sub PortfolioUndatedGaps2()

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
PortfolioUndatedGapsOpen2
PortfolioUndatedGapsClose2
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True

End Sub


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



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

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
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

Forum statistics

Threads
1,224,599
Messages
6,179,828
Members
452,946
Latest member
JoseDavid

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top