#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 371
Default Colors

Hi
I have put the hex values of colors into Range("A1:A5").
&H0&
&HFFFFFF&
&HFF&
&HFF00&
&HFF0000&

How can i iterate through the range and use the hex value? The code below
fails with 'Mismatch'

Dim frm,frmcolor
For i =1 to 5
frmcolor = Sheets(1).Cells(i , 1).Value
frm.BackColor = frmcolor
Next

Appreciate any help.

T.I.A.

Geoff
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Colors

Hi Geoff,

You need to coerce the Hex string to a value

frmcolor = Val(Sheets(1).Cells(i, 1).Value)

Be aware that in vba colours are read from Hex as BGR, not RGB as in html
#RRGGBB. However your sample colours correctly define pure black, white,
red, green & blue.

Regards,
Peter T

"Geoff" wrote in message
...
Hi
I have put the hex values of colors into Range("A1:A5").
&H0&
&HFFFFFF&
&HFF&
&HFF00&
&HFF0000&

How can i iterate through the range and use the hex value? The code below
fails with 'Mismatch'

Dim frm,frmcolor
For i =1 to 5
frmcolor = Sheets(1).Cells(i , 1).Value
frm.BackColor = frmcolor
Next

Appreciate any help.

T.I.A.

Geoff



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default Colors

You can use RGB to be consistent

Activecell.Interior.Color = RGB(&hff,&h0,&h0)

3 questions on colour today already :-)


--
HTH

Bob Phillips

"Peter T" <peter_t@discussions wrote in message
...
Hi Geoff,

You need to coerce the Hex string to a value

frmcolor = Val(Sheets(1).Cells(i, 1).Value)

Be aware that in vba colours are read from Hex as BGR, not RGB as in html
#RRGGBB. However your sample colours correctly define pure black, white,
red, green & blue.

Regards,
Peter T

"Geoff" wrote in message
...
Hi
I have put the hex values of colors into Range("A1:A5").
&H0&
&HFFFFFF&
&HFF&
&HFF00&
&HFF0000&

How can i iterate through the range and use the hex value? The code

below
fails with 'Mismatch'

Dim frm,frmcolor
For i =1 to 5
frmcolor = Sheets(1).Cells(i , 1).Value
frm.BackColor = frmcolor
Next

Appreciate any help.

T.I.A.

Geoff





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 371
Default Colors

Hi Peter T
Thanks, thats great. Just knew it had to be simple.

Geoff

"Peter T" wrote:

Hi Geoff,

You need to coerce the Hex string to a value

frmcolor = Val(Sheets(1).Cells(i, 1).Value)

Be aware that in vba colours are read from Hex as BGR, not RGB as in html
#RRGGBB. However your sample colours correctly define pure black, white,
red, green & blue.

Regards,
Peter T

"Geoff" wrote in message
...
Hi
I have put the hex values of colors into Range("A1:A5").
&H0&
&HFFFFFF&
&HFF&
&HFF00&
&HFF0000&

How can i iterate through the range and use the hex value? The code below
fails with 'Mismatch'

Dim frm,frmcolor
For i =1 to 5
frmcolor = Sheets(1).Cells(i , 1).Value
frm.BackColor = frmcolor
Next

Appreciate any help.

T.I.A.

Geoff




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
All colors in Office documents are grayscale, how do I see colors JT Excel Discussion (Misc queries) 1 February 2nd 10 02:13 PM
Used drawing colors in shapes....lost default colors for "Fill Col Lai704 Excel Discussion (Misc queries) 1 August 20th 08 04:45 AM
Worksheet formatting (fill colors & text colors) disappeared sweettooth Excel Discussion (Misc queries) 2 June 24th 08 01:16 AM
Lost highlighting and font colors; background colors on web pages Jan in Raleigh Excel Discussion (Misc queries) 2 July 31st 07 09:10 PM
Can't format font colors or cell fill-in colors canoeron Excel Discussion (Misc queries) 3 August 22nd 05 11:46 PM


All times are GMT +1. The time now is 02:45 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"