Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Loopinq question
Below is the macro that mostly works - the problem is that when it gets past a total row height, it should skip five row and start recounting - but it isn't. What am i doing wrong? Sub SetPages() Dim TotalHeight As Double Dim MaxHeight As Double Dim PRow As Integer Dim CRow As Integer Dim r As Range MaxHeight = 700 Set rngsht1 = shtVarV.Rows("57:192") TotalHeight = 0 PRow = 57 CRow = 57 For Each r In rngsht1 If IsEmpty(cell) Then PRow = CRow CRow = r.Row End If TotalHeight = TotalHeight + r.RowHeight Debug.Print ("total row height " & TotalHeight & " current row " & PRow) If TotalHeight MaxHeight Then shtVarD.Rows(PRow & ":" & PRow + 5).Insert shtVarD.Range("J" & PRow & ":J" & PRow + 3).Value = shtVarD.Range("RightVF1:RightVF4").Value shtVarD.Range("J" & PRow & ":J" & PRow + 3).HorizontalAlignment = xlRight shtVarD.Range("A" & PRow + 3).Value = shtVarD.Range("LeftVF4").Value shtVarD.Range("A" & PRow + 3).HorizontalAlignment = xlLeft shtVarD.HPageBreaks.Add befo=Cells(PRow + 4, "a") shtVarD.Range("title1").Copy shtVarD.Range("a" & PRow + 5) r = PRow + 5 Debug.Print ("total row height " & TotalHeight & " current row " & PRow) TotalHeight = 0 End If Next r Debug.Print ("total row height " & totheight) End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|