I used conditional format as suggested to get the Negative numbers Red and the Positive numbers Green. However I discovered that I couldn’t get it recorded in q Macro since record macro doesn’t recognize mouse selections.
The information changes business day and is placed in a new location when recorded
My solution to make a macro work was to copy the cells which had been conditionally styled into a specific location on a seperate sheet in the calc spreadsheet. That way I could access that specificgroup of cells by recording key strokes and then to Paste Special (Ctrl+Shift+V) with Format Only into the group of newly created info in the new group of cells of the of the base spreadsheet. Here is an example of the condional formatted cells:
Examp[e |
-99.06 |
-0.26 |
Examp[e |
55.97 |
0.36 |
Examp[e |
3.95 |
0.08 |
Examp[e |
-14.40 |
-0.73 |
Examp[e |
-0.31 |
-0.88 |
Examp[e |
-0.40 |
-1.24 |
Examp[e |
-0.06 |
-0.22 |
Examp[e |
-0.70 |
-1.25 |
Examp[e |
0.34 |
0.44 |
Examp[e |
-0.20 |
-0.90 |
Here is a copy of the Macro that was created and placed as a suproutine into my major Macro for updating that spreadsheet with everything in the right location:
sub PosGreenNegRed
rem ----------------------------------------------------------------------
rem define variables
dim document as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:JumpToNextTable", "", 0, Array())
rem ----------------------------------------------------------------------
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "ToPoint"
args1(0).Value = "$A$10"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())
rem ----------------------------------------------------------------------
dim args2(0) as new com.sun.star.beans.PropertyValue
args2(0).Name = "By"
args2(0).Value = 1
dispatcher.executeDispatch(document, ".uno:GoRightToEndOfDataSel", "", 0, args2())
rem ----------------------------------------------------------------------
dim args3(0) as new com.sun.star.beans.PropertyValue
args3(0).Name = "By"
args3(0).Value = 1
dispatcher.executeDispatch(document, ".uno:GoDownToEndOfDataSel", "", 0, args3())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Copy", "", 0, Array())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:JumpToPrevTable", "", 0, Array())
rem ----------------------------------------------------------------------
dim args4(1) as new com.sun.star.beans.PropertyValue
args4(0).Name = "By"
args4(0).Value = 3
args4(1).Name = "Sel"
args4(1).Value = false
dispatcher.executeDispatch(document, ".uno:GoLeft", "", 0, args4())
rem ----------------------------------------------------------------------
dim args6(1) as new com.sun.star.beans.PropertyValue
args6(0).Name = "By"
args6(0).Value = 1
args6(1).Name = "Sel"
args6(1).Value = false
dispatcher.executeDispatch(document, ".uno:GoUpToStartOfData", "", 0, args6())
rem ----------------------------------------------------------------------
dim args7(5) as new com.sun.star.beans.PropertyValue
args7(0).Name = "Flags"
args7(0).Value = "T"
args7(1).Name = "FormulaCommand"
args7(1).Value = 0
args7(2).Name = "SkipEmptyCells"
args7(2).Value = false
args7(3).Name = "Transpose"
args7(3).Value = false
args7(4).Name = "AsLink"
args7(4).Value = false
args7(5).Name = "MoveMode"
args7(5).Value = 4
dispatcher.executeDispatch(document, ".uno:InsertContents", "", 0, args7())
rem ----------------------------------------------------------------------
dim args8(0) as new com.sun.star.beans.PropertyValue
args8(0).Name = "By"
args8(0).Value = 9
dispatcher.executeDispatch(document, ".uno:GoDownSel", "", 0, args8())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Copy", "", 0, Array())
end sub
The reason for all the above was that I didn’t want to assign a key stroke to the conditional formating within my major upcating macro.
Thanks everyone for all your comments and help in getting me to this solution.
[erAck: edited to format code as code, see This is the guide - How to use the Ask site? - #6 by erAck]