Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Newbie: Reading color information

Word of caution: I have _never_ done any excel programming before (lots
of C++, C, Python, Java etc. though).

I have an excel file that contains 25 worksheets.

Each sheet contains (apart from som text here and there) a 12x12 grid
of cells containing mainly just color information. That is, a cell is
white, green, red, blue etc. In some of these colored cells, there is
also text.

Now, I need to extract data from these sheets into some simple format
that is easy to parse. I have tried using a Python excel reading
module, but it disregards color information.

Is there some tools that can extract data (also color information) from
excel into some simpler format (CSV is without color information too)?

Or can I make a simple excel program that puts a certain string into a
cell depending on each color? Then I can read this content with the
python module etc.

/David

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Newbie: Reading color information

If you select some cells and run this macro:

Sub colorcode()
Dim r As Range
For Each r In Selection
r.Value = r.Interior.ColorIndex
Next
End Sub


The contents of the cells will be set to the background color index.
--
Gary's Student


" wrote:

Word of caution: I have _never_ done any excel programming before (lots
of C++, C, Python, Java etc. though).

I have an excel file that contains 25 worksheets.

Each sheet contains (apart from som text here and there) a 12x12 grid
of cells containing mainly just color information. That is, a cell is
white, green, red, blue etc. In some of these colored cells, there is
also text.

Now, I need to extract data from these sheets into some simple format
that is easy to parse. I have tried using a Python excel reading
module, but it disregards color information.

Is there some tools that can extract data (also color information) from
excel into some simpler format (CSV is without color information too)?

Or can I make a simple excel program that puts a certain string into a
cell depending on each color? Then I can read this content with the
python module etc.

/David


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Newbie: Reading color information



On Nov 7, 10:08 am, Gary''s Student
wrote:
If you select some cells and run this macro:

Sub colorcode()
Dim r As Range
For Each r In Selection
r.Value = r.Interior.ColorIndex
Next
End Sub

The contents of the cells will be set to the background color index.


If you want RGB values, the Interior.Color property (I'm not sure which
XL version this appeared in, but probably 2000) returns a Long, which
can be transformed into RGB values using something like this:

Dim R As Long
Dim G As Long
Dim B As Long

R = colorValue Mod 256
G = (colorValue - R) / 256 Mod 256
B = (colorValue - R - G * 256) / 256 / 256 Mod 256

Mike

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
retrieve information from clipboards not in the reading pane JodieLeeGarcia Excel Discussion (Misc queries) 0 June 23rd 09 09:19 PM
Reading information from a closed workbook yhockman1 Excel Programming 2 March 15th 06 01:25 PM
Reading the Clipboard Source Information TCook Excel Programming 0 October 9th 05 04:49 AM
Reading a color, and setting a value Mark from Princeton Excel Programming 6 September 22nd 05 07:31 PM
Reading information from all workbooks in a folder... H. Rye Excel Programming 2 January 2nd 04 02:55 PM


All times are GMT +1. The time now is 05:55 AM.

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"