Question: Very simple vba problem, not sure where it is going wrong, but:

```
Range("J21").Select
For tastetherainbow = 1 To 1000
    skittle = ActiveCell.Offset(0, 2).Value
    Selection.Interior.Color = skittle        
    ActiveCell.Offset(1, 0).Select    
Next

```

The cell containing each appropriate skittle value contains an RGB code in the form RGB(r,g,b) , exactly as it should be for the VBA. I have tested it by copy pasting the cell's value into Selection.Interior.Color = *paste* without issue, but I get a "type mismatch" when it just uses skittle.

In fact, the only reason I am using skittle as a variable is that I had the same issue when I used `Selection.Offset(0,2).Value` to set the colour. 

Rather lost! Could you let me know how to fix it, and *why* I have this issue. 

Thanks!

Answer: 
It's recommended not using `Select` , `Selection` and `ActiveCell` , instead I preffer to start the `For` loop from Cell "J21" and just advance the row by 1.

**Code**

```
Option Explicit

Sub CellColors()

Dim Skittle As Long
Dim tastetherainbow As Long

' modify "Sheet1" to your sheet's name
With Sheets("Sheet1")
    For tastetherainbow = 1 To 1000
        Skittle = .Cells(tastetherainbow + 20, "L").Value
        .Cells(tastetherainbow + 20, "J").Interior.Color = Skittle
    Next tastetherainbow
End With

End Sub

```

**Edited Code**: converts the cell string format of "RGB(0,0,74)" to 0,0,74, then using the `Split` function putting the `String`s into 3 elements of an array.
Then calculating `Skittle` `Long` numeric value using `CInt` and the ***RGB*** method.

```
Option Explicit

Sub CellColors()

Dim Skittle As Long
Dim CellRGBStr  As String
Dim RGBInd() As String
Dim tastetherainbow As Long

With Sheets("Sheet3")
    For tastetherainbow = 1 To 1000
        If .Cells(tastetherainbow + 20, "L").Value <> "" Then

            ' use a string to store the "RGB(0,0,74)" as 0,0,74
            CellRGBStr = Mid(.Cells(tastetherainbow + 20, "L").Value, 6, Len(.Cells(tastetherainbow + 20, "L").Value) - 7)

            ' split the CellRGBStr to 3 array elements
            RGBInd = Split(CellRGBStr, ",")

            ' calculate the value of Skittle (using the RGB method)
            Skittle = (CInt(RGBInd(0))) ^ 3 + (CInt(RGBInd(1))) ^ 2 + (CInt(RGBInd(2))) ^ 1
            .Cells(tastetherainbow + 20, "J").Interior.Color = Skittle
        End If
    Next tastetherainbow
End With

End Sub

```

Another way to calculate `Skittle` is with the `RGB` function:

```
Skittle = RGB(CInt(RGBInd(0)), CInt(RGBInd(1)), CInt(RGBInd(2)))

```
```
'little modification is required in your code as follows 
Range("J21").Select
For tastetherainbow = 1 To 1000
    skittle = ActiveCell.Offset(0, 2).Value
    Selection.Interior.Color = RGB(skittle)        
    ActiveCell.Offset(1, 0).Select    
Next

```