Hi all
I wish to colour a range of cells in a newly inserted line. I have no trouble inserting the line but my code for identifying the cells is not compatible. The code trips on the ".Interior.Color" line.
Any help is much appreciated.
Regards Mark
Thread moved to VBA Macros
I wish to colour a range of cells in a newly inserted line. I have no trouble inserting the line but my code for identifying the cells is not compatible. The code trips on the ".Interior.Color" line.
Code:
.Rows(lRow & myRange).Interior.Color = 9868950
Code:
Sub InsertRows_SeparateCranes() 'separate by Earl.start date, then by Oper.WorkCenter
Const s = "Cranes"
Dim FX5 As String
Dim lRow As Long
Dim lastrow As Long
Dim myRange As Range
Set myRange = Range("B:O")
FX5 = "=IF(LEN(B2)>0,F2,F1)" 'inserts dates into helper column to allow for separation of days
lastrow = Sheets(s).Range("B" & Rows.Count).End(xlUp).Row
With Sheets(s)
.Range("R2:R" & lastrow).Formula = FX5 'R = helper column
End With
With Sheets(s)
For lRow = .Cells(.Rows.Count, "A").End(xlUp).Row To 3 Step -1
If .Cells(lRow, "R") <> .Cells(lRow - 1, "R") Then 'R = helper column
.Rows(lRow).EntireRow.Insert 'insert rows between date changes for each RWC
.Rows(lRow).EntireRow.RowHeight = 6
.Rows(lRow & myRange).Interior.Color = 9868950
End If
Next lRow
End With
End Sub
Any help is much appreciated.
Regards Mark
Thread moved to VBA Macros
Attachments
Last edited by a moderator: