Hi all, first post, but long-time appreciator of OzGrid. Got a quirky one.
Range(...).Interior.Color = vbRed (or any other color) during Workbook_Open sub results in Run-time error 1004, Application- or object-defined error.
Preceding lines that reference the same cell do not, and work as expected. Code follows...
Code
Private Sub Workbook_Open()
' Constant initialisation...
Set Main_worksheet = ThisWorkbook.Worksheets(Transactions_wsname)
' Code start...
If InDeveloperMode Then
Range(NeutralCell).Value = "Developer Mode"
Range(NeutralCell).Interior.Color = vbRed
Else
Range(NeutralCell).Value = ""
Range(NeutralCell).Interior.Color = xlNone
Call Main_Workbook_Open
End If
End Sub
Display More
In the above, the cell value is correctly set, but the sub fails on setting the color.
NeutralCell is defined in a Public_Declarations module as follows:-
Debug shows NeutralCell = "L1", range is correctly set, and vbRed is 255.
The same error occurs on the corresponding lines after Else (i.e. not InDeveloperMode). The value is cleared, and the color set gives error 1004.
Any ideas?
Thanks, John.