| View previous topic :: View next topic |
| Author |
Message |
DMakurat General User

Joined: 05 Oct 2006 Posts: 15
|
Posted: Mon Oct 09, 2006 7:20 pm Post subject: How can I get the color of data |
|
|
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 |
|
 |
carl Super User


Joined: 21 Apr 2003 Posts: 920 Location: Germany
|
Posted: Mon Oct 09, 2006 10:32 pm Post subject: |
|
|
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 |
|
 |
DMakurat General User

Joined: 05 Oct 2006 Posts: 15
|
Posted: Tue Oct 10, 2006 7:12 am Post subject: |
|
|
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 |
|
 |
Villeroy Super User


Joined: 04 Oct 2004 Posts: 10065 Location: Germany
|
Posted: Tue Oct 10, 2006 8:52 am Post subject: |
|
|
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 http://forum.openoffice.org |
|
| Back to top |
|
 |
|