Problem with cells color VB
Hi,
I have a table with changing length of the rows and columns and sums at the end of each row/table/diagonal. I want to put some color to the table, but I get error 438 - Object doesn't support this property or method. Here is the code I have:
Code:
Sub ColorSet()
Dim cLL As Range, Rg As Range
Application.ScreenUpdating = False
For Each cLL In Range("A1:P10")
If IsEmpty(cLL) Then
With cLL.Interior
.ColorIndex = 0
.Pattern = xlSolid
End With
Else
With cLL.Interior
.ColorIndex = 3
.Pattern = xlSolid
.LineStyle = xlContinuous
End With
End If
Next cLL
Application.ScreenUpdating = True
End Sub
Could you help me as I can't figure out what the problem is...
Re: Problem with cells color VB
Microsoft has confirmed this to be a bug in the Microsoft products. There are two possible workarounds for this problem.
- Access the form directly rather than by a variable containing the form.
OR
- Create property procedures in the form's code to provide access to the properties of the controls on the form.
Re: Problem with cells color VB
Could you explain the worarounds in more details?
Re: Problem with cells color VB
Which version of VB are you using... I have run into all kinds of errors in VB.net 2008. One big problem was the way it colors things instead of putting
x
.background.color.RED
. some other property
. some other property
i had to type the item lets say
x.background.color.RED
x.some other property
x. some other property
Re: Problem with cells color VB
The version is Microsoft Visual Basic 6.5
So do I understand right that you mean putting it this way?
Code:
Sub ColorSet()
Dim cLL As Range, Rg As Range
'Set Rg = Range("A1:P10")
Application.ScreenUpdating = False
For Each cLL In Range("A1:P10")
If IsEmpty(cLL) Then
cLL.Interior.ColorIndex = 0
cLL.Interior.Pattern = xlSolid
Else
cLL.Interior.ColorIndex = 3
cLL.Interior.Pattern = xlSolid
cLL.Interior.LineStyle = xlContinuous
End If
Next cLL
Application.ScreenUpdating = True
End Sub
If yes - it gives me the same mistake...
Re: Problem with cells color VB
no that only works in vb.net--- I threw that out there in case you were using VB.net