I have the following code that I'm using to try and count colour fill of cells in a specified range on another worksheet, and I can't get it to quite work how I want.
The code that I can get working how I want is this:
But instead of using column reference "M" in the range, I want to use twelvewk column identifier like this
I can't get it working like this at all!.... it's probably something obvious - can anyone help?
Many thanks
Tom
The code that I can get working how I want is this:
Code:
twowk = Sheets("PROD").Range("2:2").Find(What:="2WK GATE DATE", lookat:=xlWhole, MatchCase:=False).Columnsixwk = Sheets("PROD").Range("2:2").Find(What:="6WK GATE DATE", lookat:=xlWhole, MatchCase:=False).Column
twelvewk = Sheets("PROD").Range("2:2").Find(What:="12WK GATE DATE", lookat:=xlWhole, MatchCase:=False).Column
Lrow = Sheets("PROD").Cells(Rows.Count, 1).End(xlUp).Row
For nRowIndex = 3 To Lrow
If Sheets("PROD").Range("M" & nRowIndex).Interior.ColorIndex = 3 Then 'red
nCellNumber = nCellNumber + 1
End If
If Sheets("PROD").Range("M" & nRowIndex).Interior.ColorIndex = 46 Then 'orange
nCellNumber2 = nCellNumber2 + 1
End If
Next nRowIndex
But instead of using column reference "M" in the range, I want to use twelvewk column identifier like this
Code:
twowk = Sheets("PROD").Range("2:2").Find(What:="2WK GATE DATE", lookat:=xlWhole, MatchCase:=False).Columnsixwk = Sheets("PROD").Range("2:2").Find(What:="6WK GATE DATE", lookat:=xlWhole, MatchCase:=False).Column
twelvewk = Sheets("PROD").Range("2:2").Find(What:="12WK GATE DATE", lookat:=xlWhole, MatchCase:=False).Column
Lrow = Sheets("PROD").Cells(Rows.Count, 1).End(xlUp).Row
For nRowIndex = 3 To Lrow
If Sheets("PROD").Range(twelvewk & nRowIndex).Interior.ColorIndex = 3 Then 'red
nCellNumber = nCellNumber + 1
End If
If Sheets("PROD").Range(twelvewk & nRowIndex).Interior.ColorIndex = 46 Then 'orange
nCellNumber2 = nCellNumber2 + 1
End If
Next nRowIndex
I can't get it working like this at all!.... it's probably something obvious - can anyone help?
Many thanks
Tom