error!

P

porkie

hi all,

i used the code below to fill colours into my cell.. however upon
running it, it gives me an error of Run-time error '91' : Object
variable or With block variable not set

i have another set of codes that is identical except that it uses
ActiveCell.Font.ColorIndex bcos it is meant for setting the font
colours of the text and it runs well..

anyone can help? thanks!

the code with error:

Public Sub test2()
Dim cellColour As Range
For Each cell In Range("B5:BA100")
cellColour.Activate
If ActiveCell = "PC" Then
ActiveCell.Interior.ColorIndex = 1
ElseIf ActiveCell = "O" Then
ActiveCell.Interior.ColorIndex = 1
ElseIf ActiveCell = "W" Then
ActiveCell.Interior.ColorIndex = 1
ElseIf ActiveCell = "PS" Then
ActiveCell.Interior.ColorIndex = 1
ElseIf ActiveCell = "P" Then
ActiveCell.Interior.ColorIndex = 1
ElseIf ActiveCell = "L" Then
ActiveCell.Interior.ColorIndex = 1
ElseIf ActiveCell = "PSC" Then
ActiveCell.Interior.ColorIndex = 1
ElseIf ActiveCell = "LVP" Then
ActiveCell.Interior.ColorIndex = 1
ElseIf ActiveCell = "S" Then
ActiveCell.Interior.ColorIndex = 1
ElseIf ActiveCell = "B" Then
ActiveCell.Interior.ColorIndex = 1
ElseIf ActiveCell = "A" Then
ActiveCell.Interior.ColorIndex = 1
Else
End If
Next
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top