why wont this work

The Idea Dude

Well-known Member
Joined
Aug 15, 2002
Messages
585
For Each c In Worksheets("Sheet2").Range("B2:B48").Cells
If c.Interior.ColorIndex.Value = 6 Then c.Value = 0.5
Next



thanks :)
 

Some videos you may like

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

pgc01

MrExcel MVP
Joined
Apr 25, 2006
Messages
19,834
Hi

ColorIndex is a property and so you cannot use ColorIndex.Value.

Try:
Code:
Sub test()
Dim c As Range

For Each c In Worksheets("Sheet2").Range("B2:B48")
    If c.Interior.ColorIndex = 6 Then c.Value = 0.5
Next
End Sub

I removed the .cells because it does nothing.

Hope this helps
PGC
 

Watch MrExcel Video

Forum statistics

Threads
1,108,910
Messages
5,525,587
Members
409,652
Latest member
strangelyangely

This Week's Hot Topics

Top