Inserting text in bottom three rows of each page break of worksheet (without huge IF statement)

WingSystems

New Member
Joined
Aug 24, 2016
Messages
15
Office Version
  1. 365
Platform
  1. Windows
Hi All,
Have a couple questions regarding code, here is breakdown.

Goal: Insert text in bottom three rows of each page of worksheet without having to write gigantic if statement.

Current Situation:


  • We have legal jargon that needs to be added to the bottom of each page of a worksheet.
  • Worksheets have a report that is being added by an Excel add-in
  • Each sheet has a variable amount of reports filling it (x number of times based on number of stores in system) creating said pages. Some sheets end up breaking into 7 pages, some 1 page, etc.
  • LUCKILY, each report filling sheets has a consistent number of rows/columns.

Question:

  • How could I code this in a way that isn’t tied to specific cells/rows, but perhaps maybe a single if statement that keeps running until an END…so that I don’t have to write long If statement to circumvent the variability in number of reports entered.
  • For example instead of

Range("A65").EntireRow.Offset(1).Resize(3).Insert Shift:=xlDown
Rows("66").RowHeight = 85
Rows("67").RowHeight = 131
Rows("68").RowHeight = 196
Range("A66:O66").Merge
Range("A67:O67").Merge
Range("A68:O68").Merge

Do something like this:

If Xrow not blank, on the +65th row run…etc.,etc
Range(XRow + 65").EntireRow.Offset(1).Resize(3).Insert Shift:=xlDown
Rows(XRow + 66").RowHeight = 85
Rows(XRowl +67).RowHeight = 131
Etc.

Full Code:
----
Dim ws As Worksheet
Set ws = ThisWorkbook.ActiveSheet

With ws
Range("A65").EntireRow.Offset(1).Resize(3).Insert Shift:=xlDown
Rows("66").RowHeight = 85
Rows("67").RowHeight = 131
Rows("68").RowHeight = 196
Range("A66:O66").Merge
Range("A67:O67").Merge
Range("A68:O68").Merge
Range("A66") = "TEXT"
Range("A67") = "TEXT"
Range("A68") = "TEXT" _
& "TEXT"
Range("A66").HorizontalAlignment = xlCenter
Range("A66").VerticalAlignment = xlCenter
Range("A67").HorizontalAlignment = xlCenter
Range("A67").VerticalAlignment = xlCenter
Range("A68").HorizontalAlignment = xlCenter
Range("A68").VerticalAlignment = xlCenter
Range("A66").WrapText = True
Range("A67").WrapText = True
Range("A68").WrapText = True
Rows("69").PageBreak = xlPageBreakManual
End With
End Sub


I really appreciate any help….and apologize if this made no sense...also feel free to call me out on any poor coding :)

- Regards
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

Forum statistics

Threads
1,216,075
Messages
6,128,667
Members
449,462
Latest member
Chislobog

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