WingSystems
New Member
- Joined
- Aug 24, 2016
- Messages
- 15
- Office Version
- 365
- Platform
- 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:
Question:
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
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 isnt tied to specific cells/rows, but perhaps maybe a single if statement that keeps running until an END so that I dont 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