Dynamic print to two pages

TGwilding

Board Regular
Joined
Jun 13, 2005
Messages
65
I have the following code that unhides rows if a question is answered yes and leaves rows hidden if the question is answered no:

Private Sub Worksheet_Change(ByVal Target As Range)


If Target.Cells.Count > 1 Then Exit Sub

Application.EnableEvents = False


If Target.Address(0, 0) = "J147" And Target <> "" Then Rows("149:154").Hidden = False

If Target.Address(0, 0) = "J147" And Target = "" Then Rows("149:154").Hidden = True


If Target.Address(0, 0) = "J129" And Target <> "" Then Rows("130:139").Hidden = False

If Target.Address(0, 0) = "J129" And Target = "" Then Rows("130:139").Hidden = True


If Target.Address(0, 0) = "J62" And Target <> "" Then Rows("72:75").Hidden = False

If Target.Address(0, 0) = "J62" And Target = "" Then Rows("72:75").Hidden = True

Application.EnableEvents = True


If Target.Cells.Count > 1 Then Exit Sub


If Intersect(Target, [J:J]) Is Nothing Then Exit Sub

Application.EnableEvents = False


If Target <> "" Then Rows(Target.Row + 1 & ":" & Target.Row + 2).Hidden = False

If Target.Address(0, 0) = "J14" And Target = "" Then Rows("15:16").Hidden = True

If Target.Address(0, 0) = "J18" And Target = "" Then Rows("19:20").Hidden = True

If Target.Address(0, 0) = "J23" And Target = "" Then Rows("24:25").Hidden = True

If Target.Address(0, 0) = "J28" And Target = "" Then Rows("29:30").Hidden = True

If Target.Address(0, 0) = "J32" And Target = "" Then Rows("33:34").Hidden = True

If Target.Address(0, 0) = "J36" And Target = "" Then Rows("37:38").Hidden = True

If Target.Address(0, 0) = "J54" And Target = "" Then Rows("55:56").Hidden = True

If Target.Address(0, 0) = "J58" And Target = "" Then Rows("59:60").Hidden = True

If Target.Address(0, 0) = "J78" And Target = "" Then Rows("79:80").Hidden = True

If Target.Address(0, 0) = "J83" And Target = "" Then Rows("84:85").Hidden = True

If Target.Address(0, 0) = "J88" And Target = "" Then Rows("89:90").Hidden = True

If Target.Address(0, 0) = "J95" And Target = "" Then Rows("96:97").Hidden = True

If Target.Address(0, 0) = "J102" And Target = "" Then Rows("103:104").Hidden = True

If Target.Address(0, 0) = "J114" And Target = "" Then Rows("115:116").Hidden = True

If Target.Address(0, 0) = "J118" And Target = "" Then Rows("119:120").Hidden = True

If Target.Address(0, 0) = "J125" And Target = "" Then Rows("126:127").Hidden = True

If Target.Address(0, 0) = "J141" And Target = "" Then Rows("142:143").Hidden = True



Application.EnableEvents = True


End Sub

the code is working great, however, I would like it to automatically adjust the page setup so that when I print, it will print everything in two pages regardless of how many rows are hidden or unhidden.

Any help would be appreciated.
thanks
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

RalphA

Well-known Member
Joined
May 14, 2003
Messages
3,829
You wrote:
would like it to automatically adjust the page setup so that when I print, it will print everything in two pages regardless of how many rows are hidden or unhidden.
Accordint to the above, as long as all the rows can be fitted into two pages, you will be able to print any amount of rows less that the total in the same two pages or less.
 

Forum statistics

Threads
1,141,756
Messages
5,708,332
Members
421,565
Latest member
Lastadiego

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
Top