OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

How can I get the color of data

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Calc
View previous topic :: View next topic  
Author Message
DMakurat
General User
General User


Joined: 05 Oct 2006
Posts: 15

PostPosted: Mon Oct 09, 2006 7:20 pm    Post subject: How can I get the color of data Reply with quote

I am importing HTML tables into a spreadsheet. Positive numbers are green and negative ones are red.

I need to write a macro to manipulate the numbers.

Is there a way to determine the color of the number so I can tell which are positive and which are negative?
Back to top
View user's profile Send private message
carl
Super User
Super User


Joined: 21 Apr 2003
Posts: 920
Location: Germany

PostPosted: Mon Oct 09, 2006 10:32 pm    Post subject: Reply with quote

In Format /cell/numbers/ there is an option that shows black for positve and red for negative.
If you want another colouryou can adapt the option in the "FORMAT CODE box. just change the name of the colour from red and hit the tick.
_________________
carl
Using OpenOffice.org 2 on XP sp2
Back to top
View user's profile Send private message
DMakurat
General User
General User


Joined: 05 Oct 2006
Posts: 15

PostPosted: Tue Oct 10, 2006 7:12 am    Post subject: Reply with quote

Thank you for the response. However, I am working on detecting the color rather than changing it.

I used a "DisplayMethods" subroutine from Andrew Pitonyak's Macro write up and found that there is CharColor property of the cell. I can then use Red(color) to get the red component.
Back to top
View user's profile Send private message
Villeroy
Super User
Super User


Joined: 04 Oct 2004
Posts: 10106
Location: Germany

PostPosted: Tue Oct 10, 2006 8:52 am    Post subject: Reply with quote

Your imported cells have red fonts instead of negative values?
Save my collection of introspective cell functions in basic-container "My Macros", library "Standard" and add this:

Code:

Function CELL_CHARCOLOR(vSheet,lRowIndex&,iColIndex%)
Dim v
   v = getSheetCell(vSheet,lRowIndex&,iColIndex%)
   if vartype(v) = 9 then
      CELL_CHARCOLOR = v.CharColor
   else
      CELL_CHARCOLOR = v
   endif
End Function

=CELL_CHARCOLOR(SHEET();ROW();1)
returns the color-code of the cell in this sheet's first column in this row.
For instance 16711680 (Dec2Hex(16711680
)->"FF0000")

=IF(CELL_CHARCOLOR(SHEET();ROW();1)=16711680;-$A1;$A1)
does the conversion.
_________________
Rest in peace, oooforum.org
Get help on https://forum.openoffice.org
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Calc All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group