P
pallaver
A brief explanation:
I have 3 columns of data: X, Y, and Z. User inputs a high/low ranger
(i.e. 4 +3/-2, i.e. 2 to 7). If the number is outside of that range,
I have used conditional format to set the cell color to gray.
Now here's where I have a problem.
I'm attempting to add a fourth column, OK/NG column. If either of the
X, Y, or Z cells in a row are gray, then the fourth box also turns
gray and displays NG. Otherwise it will display OK (i.e. all XYZ
points are within spec).
I did a little test myself, and it seems as though the code below
works if you change the cell interior color on the excel spreadsheet,
but when the cell color is changed due to conditional formatting, the
macro reads the cell as a normal cell and displays OK for all entries.
For RowCounter = 1 to 10
If Sheets("Sheet1").Cells(RowCounter, 1).Interior.Pattern = xlSolid
Then
Sheets("Sheet1").Cells(RowCounter, 2).Value = "NG"
With Sheets("Sheet1").Cells(RowCounter, 2).Interior
.ColorIndex = 15
.Pattern = xlSolid
End With
Else
Sheets("Sheet1").Cells(RowCounter, 2).Value = "OK"
End If
Next RowCounter
------
Anybody else encountered this problem? Any way I can properly
identify a colored cell from conditional format in the macro?
Thanks. NP
I have 3 columns of data: X, Y, and Z. User inputs a high/low ranger
(i.e. 4 +3/-2, i.e. 2 to 7). If the number is outside of that range,
I have used conditional format to set the cell color to gray.
Now here's where I have a problem.
I'm attempting to add a fourth column, OK/NG column. If either of the
X, Y, or Z cells in a row are gray, then the fourth box also turns
gray and displays NG. Otherwise it will display OK (i.e. all XYZ
points are within spec).
I did a little test myself, and it seems as though the code below
works if you change the cell interior color on the excel spreadsheet,
but when the cell color is changed due to conditional formatting, the
macro reads the cell as a normal cell and displays OK for all entries.
For RowCounter = 1 to 10
If Sheets("Sheet1").Cells(RowCounter, 1).Interior.Pattern = xlSolid
Then
Sheets("Sheet1").Cells(RowCounter, 2).Value = "NG"
With Sheets("Sheet1").Cells(RowCounter, 2).Interior
.ColorIndex = 15
.Pattern = xlSolid
End With
Else
Sheets("Sheet1").Cells(RowCounter, 2).Value = "OK"
End If
Next RowCounter
------
Anybody else encountered this problem? Any way I can properly
identify a colored cell from conditional format in the macro?
Thanks. NP