B
Bishop
I have the following code:
Sub DirectorFormat()
Dim TSLastPFRow As Integer 'Tally Sheet
Dim TSPFTotal As Integer 'Tally Sheet PF
Dim ZeroRow As Long, i As Long
With Sheets("Tally Sheet")
.Cells.Copy
.Paste Destination:=Worksheets("DirectorCopy").Range("A1")
End With
With Worksheets("DirectorCopy")
.Shapes("LazyEyeButton").Cut
For j = 1 To 64
.Shapes("Done! " & j).Cut
Next
.Columns("G:G").Delete
.Cells.Copy
.Cells.PasteSpecial Paste:=xlPasteValues,
Operation:=xlPasteSpecialOperationNone, _
SkipBlanks:=False, Transpose:=False
'Find the last PF
For i = 4 To Rows.Count Step 8
If Cells(i, "A").Value = 0 Then
ZeroRow = i
Exit For
End If
Next
TSLastPFRow = ZeroRow - 9
TSPFTotal = (Val(Replace(Cells(TSLastPFRow, 1).Value, "_PF", "")))
'Delete empty PFs at the bottom
.Range(ZeroRow & ":515").Delete
'Delete all title bars except the first one
For i = (ZeroRow - 7) To 13 Step -8
.Rows(i).Delete
Next
'Move the last title bar up 2 rows
.Rows(5).Select
Selection.Cut
.Rows(3).Select
Selection.Insert Shift:=xlDown
.Rows(4).Select
ActiveWindow.FreezePanes = True
End With
End Sub
At .Rows(5).Select I keep getting error Select method of Range class failed.
I read the help file and I think I have the format right. Is .Select
causing the issue? How do I select that row otherwise?
Sub DirectorFormat()
Dim TSLastPFRow As Integer 'Tally Sheet
Dim TSPFTotal As Integer 'Tally Sheet PF
Dim ZeroRow As Long, i As Long
With Sheets("Tally Sheet")
.Cells.Copy
.Paste Destination:=Worksheets("DirectorCopy").Range("A1")
End With
With Worksheets("DirectorCopy")
.Shapes("LazyEyeButton").Cut
For j = 1 To 64
.Shapes("Done! " & j).Cut
Next
.Columns("G:G").Delete
.Cells.Copy
.Cells.PasteSpecial Paste:=xlPasteValues,
Operation:=xlPasteSpecialOperationNone, _
SkipBlanks:=False, Transpose:=False
'Find the last PF
For i = 4 To Rows.Count Step 8
If Cells(i, "A").Value = 0 Then
ZeroRow = i
Exit For
End If
Next
TSLastPFRow = ZeroRow - 9
TSPFTotal = (Val(Replace(Cells(TSLastPFRow, 1).Value, "_PF", "")))
'Delete empty PFs at the bottom
.Range(ZeroRow & ":515").Delete
'Delete all title bars except the first one
For i = (ZeroRow - 7) To 13 Step -8
.Rows(i).Delete
Next
'Move the last title bar up 2 rows
.Rows(5).Select
Selection.Cut
.Rows(3).Select
Selection.Insert Shift:=xlDown
.Rows(4).Select
ActiveWindow.FreezePanes = True
End With
End Sub
At .Rows(5).Select I keep getting error Select method of Range class failed.
I read the help file and I think I have the format right. Is .Select
causing the issue? How do I select that row otherwise?