Originally Posted by
Roderick_E
I like this array approach best. Thanks everyone.
I was hoping there was just a simple function that would turn "red" into vbred. I think I'll create a ud function for this.
Unisex Converse Adults Adults Converse Converse Unisex Unisex Converse Adults Unisex Converse Adults Code:
Function xlcolors(color As String)
Dim arrColors, vbaColors, lngIndex As Long
arrColors = Array("Black", "White", "Red", "Green", "Blue", "Yellow", "Magenta", "Cyan")
vbaColors = Array(vbBlack, vbWhite, vbRed, vbGreen, vbBlue, vbYellow, vbMagenta, vbCyan)
'cell colors
lngIndex = Application.Match(color, arrColors, 0) - 1
xlcolors = vbaColors(lngIndex)
End Function
Unisex Adults Converse Converse Converse Adults Unisex Adults Converse Converse Unisex Adults Unisex Code:
sub test
activecell.interior.color = xlcolors("Red")
end sub
could also do activecell.font.color = xlcolors("Red")
This is for when "Red" is a dynamic or what's in arrColors otherwise you could just use activecell.XXX = vbred
Like this thread? Share it with others