B
Brad
What the macro is trying to do is to look at the text in column A and insert
a page break in-between paragraphs (after the text exceeds a certain length)
......
Currently, the logic is bombing at
Set Cellcheck = shtGPA9D("A55:A176").Range
What am I doing wrong??
Sub test3()
Dim TotalHeight As Double
Dim MaxHeight As Double
Dim PRow As Integer
Dim CRow As Integer
Dim rngsht As Range
Dim Cellcheck As Range
MaxHeight = 77
Set rngsht1 = shtGPA9D.Rows("55:176")
Set Cellcheck = shtGPA9D("A55:A176").Range
TotalHeight = 0
PRow = 0
CRow = 0
For Each r In rngsht1
If Cellcheck(r) = " " Then
PRow = CRow + 54
CRow = r + 54
End If
TotalHeight = TotalHeight + r.RowHeight
If TotalHeight > MaxHeight Then
shtGPA9D.Rows(PRow & ":" & PRow + 3).Insert
shtGPA9D.Range("J" & PRow & ":J" & PRow + 57).Value =
shtGPA9D.Range("RightVF1:RightVF4").Value
shtGPA9D.Range("J" & PRow + 54 & ":J" & PRow +
57).HorizontalAlignment = xlRight
shtGPA9D.HPageBreaks.Add before:=Cells(PRow + 4, "a")
shtGPA9D.Range("title1").Copy shtGPA9D.Range("a" & PRow + 4)
TotalHeight = 0
End If
Next r
End Sub
a page break in-between paragraphs (after the text exceeds a certain length)
......
Currently, the logic is bombing at
Set Cellcheck = shtGPA9D("A55:A176").Range
What am I doing wrong??
Sub test3()
Dim TotalHeight As Double
Dim MaxHeight As Double
Dim PRow As Integer
Dim CRow As Integer
Dim rngsht As Range
Dim Cellcheck As Range
MaxHeight = 77
Set rngsht1 = shtGPA9D.Rows("55:176")
Set Cellcheck = shtGPA9D("A55:A176").Range
TotalHeight = 0
PRow = 0
CRow = 0
For Each r In rngsht1
If Cellcheck(r) = " " Then
PRow = CRow + 54
CRow = r + 54
End If
TotalHeight = TotalHeight + r.RowHeight
If TotalHeight > MaxHeight Then
shtGPA9D.Rows(PRow & ":" & PRow + 3).Insert
shtGPA9D.Range("J" & PRow & ":J" & PRow + 57).Value =
shtGPA9D.Range("RightVF1:RightVF4").Value
shtGPA9D.Range("J" & PRow + 54 & ":J" & PRow +
57).HorizontalAlignment = xlRight
shtGPA9D.HPageBreaks.Add before:=Cells(PRow + 4, "a")
shtGPA9D.Range("title1").Copy shtGPA9D.Range("a" & PRow + 4)
TotalHeight = 0
End If
Next r
End Sub