LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Get ColorIndex Number for Cell in a Range

Is there a way to directly read in the colorindex of cell into an
array? As you can see by the code below, I can get the value ok but
not the colorindex value. I know I could probably do a "For Each Cell
in Range("A1:C5")" type of command and get the colorindex number that
way but I thought the code below should work. Any ideas?

Sub GetCellValueAndColor()

' cell A1 contains the number 123 and the font color is Red
' ColorIndex number for Red is 3

Dim ArrayCellValue As Variant, ArrayCellColor As Variant

ArrayCellValue = Range("A1:C5").Value
ArrayCellColor = Range("A1:C5").Font.ColorIndex

MsgBox ArrayCellValue(1, 1) ' displays 123

' display A1 Only for test
MsgBox Range("A1").Font.ColorIndex ' displays 3

MsgBox ArrayCellColor(1, 1) 'Type mismatch
MsgBox Str(ArrayCellColor(1, 1)) 'Type mismatch
MsgBox Val(ArrayCellColor(1, 1)) 'Type mismatch
MsgBox CStr(ArrayCellColor(1, 1)) 'Type mismatch

End Sub

 
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
tab.colorindex linked to cell color Mike Excel Worksheet Functions 2 April 12th 07 12:44 AM
How to get cell colorindex of conditional formatted cells [email protected] Excel Discussion (Misc queries) 5 December 2nd 06 01:07 PM
Cell.interior.colorindex - does not work in Excel 97 Ian[_13_] Excel Programming 10 April 5th 05 07:28 PM
Name of color for a particular colorindex number Hari[_3_] Excel Programming 2 June 8th 04 07:13 PM
need to set a cell background color which is not within the Excel colorindex range Oscar Excel Programming 6 December 6th 03 11:53 AM


All times are GMT +1. The time now is 05:48 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"