I wrote this VBA script to add some colour & text formatting to a pivot table >
The code loops thru column 'C' & examines certain cells in each line of the spreadsheet, adding some formatting as it loops thru to enhance readability (see image below) >
Question: I want to insert a new empty row under the orange formatted line above, to enhance readability.
The code loops thru column 'C' & examines certain cells in each line of the spreadsheet, adding some formatting as it loops thru to enhance readability (see image below) >
VBA Code:
Private Sub Cell_Color_Change()
For Each cell In Range("C:C")
If cell.Value <> "" Then
Range(cell.Address).Offset(0, 0).Interior.colorIndex = 35
Range(cell.Address).Offset(0, 1).Interior.colorIndex = 35
ElseIf Range(cell.Address).Offset(0, -1).Value <> "" Then
Range(cell.Address).Offset(0, -1).Interior.colorIndex = 27
Range(cell.Address).Offset(0, 0).Interior.colorIndex = 27
Range(cell.Address).Offset(0, 1).Interior.colorIndex = 27
Range(cell.Address).Offset(0, 1).Font.Bold = True
ElseIf ((Range(cell.Address).Offset(0, -2).Value <> "") And (Range(cell.Address).Offset(0, -1).Value = "") And (Range(cell.Address).Offset(0, 0).Value = "")) Then
Range(cell.Address).Offset(0, -2).Interior.colorIndex = 46
Range(cell.Address).Offset(0, -1).Interior.colorIndex = 46
Range(cell.Address).Offset(0, 0).Interior.colorIndex = 46
Range(cell.Address).Offset(0, 1).Interior.colorIndex = 46
Range(cell.Address).Offset(0, -2).Font.Bold = True
Range(cell.Address).Offset(0, -1).Font.Bold = True
Range(cell.Address).Offset(0, 0).Font.Bold = True
Range(cell.Address).Offset(0, 1).Font.Bold = True
Range(cell.Address).Offset(0, -2).Font.Size = 12
Range(cell.Address).Offset(0, -1).Font.Size = 12
Range(cell.Address).Offset(0, 0).Font.Size = 12
Range(cell.Address).Offset(0, 1).Font.Size = 12
' [B]add code here to insert a blank row under the current position in Range() [/B]
End If
Next cell
End Sub
Question: I want to insert a new empty row under the orange formatted line above, to enhance readability.