I'm trying to apply the VbColor properties in a dynamic way. I have kept the basic colour in one dropdown list in Excel (Blue, Red, Yellow etc.,) and I have tried the following code to apply the colour based on the value selected in the list. But I end up getting an error (Type Mismatch - Runtime error -13).
Dim Q3Sht As Worksheet
Dim Colours As Variant
Set Q3Sht = ThisWorkbook.Sheets("Q3 Sol")
If ActiveCell.Column > 9 Then
MsgBox "Please select the Data within range", vbExclamation + vbOKOnly
Exit Sub
End If
Colours = "vb" & Q3Sht.Range("K5").Value
If ActiveCell.Column > 1 Then
ActiveCell.End(xlToLeft).Select
Range(ActiveCell, ActiveCell.Offset(0, 8)).Select
Selection.Interior.Color = Colours ' I'm getting error applying the colour
'Q3Sht.Range("K5").Interior.Color = vbBlue
Else:
Range(ActiveCell, ActiveCell.Offset(0, 8)).Select
Selection.Interior.Color = "vb" & Q3Sht.Range("K5")
Please help!! Thank you in advance.