You can put this code into the ThisWorkbook code module as a Workbook_Open
event code and it will run each time you open the workbook. you would have
to substitute the actual sheet name where ActiveSheet now appears, i.e. Set
sh = Sheets("Sheet1").
The title line would appear as :
Private Sub Workbook_Open()
'The code here
End Sub
Or you can put it in the worksheet where the data is loaded as a
Worksheet_Change event code and it will run each time a change is made to
the worksheet so that any additions or indenture changes are updated in real
time. The title line for this would appear as:
Private Sub Worksheet_Change(ByVal Target As Range)
'you would probably want to insert this line of code as the first line.
If Intersect(Target, Range("A
") ) Is Nothing Then Exit Sub
'The rest of the code here
End Sub
Dim sh As Worksheet, rng As Range, myArr As Variant
Dim lr As Long
Set sh = ActiveSheet
lr = sh.Cells.Find(What:="*", After:=sh.Range("A1"), LookAt:=xlPart, _
LookIn:=xlFormulas, SearchOrder:=xlByRows, SearchDirection:=xlPrevious, _
MatchCase:=False).Row
Set rng = Range("A1:A" & lr) '<<<Set actual range
For Each c In rng
If WorksheetFunction.CountA(sh.Range(c.Address, _
c.Offset(0, 2))) = 0 Then
Rows(c.Row).Interior.ColorIndex = 3
ElseIf WorksheetFunction.CountA(sh.Range(c.Address, _
c.Offset(0, 1))) = 0 Then
Rows(c.Row).Interior.ColorIndex = 4
ElseIf WorksheetFunction.CountA(c) = 0 Then
Rows(c.Row).Interior.ColorIndex = 5
ElseIf Not IsEmpty(c) Then
Rows(c.Row).Interior.ColorIndex = 6
End If
Next
This will work for Indenture A through D. If you need more than that, you
can play with the code by adding additional ElseIf lines and extending the
offset range to cover more blank cells on a row.