Jane Panovski
Jane Panovski

Reputation: 13

Run-Time error '438' "Object doesn't support this property or method"

I get the '438' error and when i Debug, the following line is highlighted yellow

If (Sheet4.Cells(i, j).ColorIndex <> xlNone) Then

I can't find the reason why I get this error. Is it syntax error? Or is it a bigger problem? I need to see or change colors of a Cell many times in my code. Any ideas?

Upvotes: 0

Views: 1238

Answers (1)

user4039065
user4039065

Reputation:

A Range.Cells property does not have a .ColorIndex property. However, its .Interior or possibly its .Font can have a .ColorIndex. To check whether the Fill of a cell is colored, you can check the .Pattern against xlNone.

'for Fill
If Sheet4.Cells(i, j).Interior.Pattern <> xlNone Then
'for Font
If Sheet4.Cells(i, j).Font.ColorIndex <> xlAutomatic Then

Checking the font colorindex against xlColorIndexAutomatic might be a better approach. Your question is lacking some specifics.

Upvotes: 1

Related Questions