| View previous topic :: View next topic |
| Author |
Message |
JZA OOo Advocate


Joined: 01 Feb 2003 Posts: 432 Location: Mexico
|
Posted: Fri Jun 08, 2007 11:37 pm Post subject: Formating a SpreadSheet Background |
|
|
I want to know how can I select a row and format the background from OOoBasic. So far the Macro recorder doesn't seem to pick up when I select the row.
I need to:
a) select a row
b) specify the background color
c) loop the process every other row.
I guess the double loop is not an issue, however I want to know how to select the row and specify the background color. _________________ Alexandro Colorado
PPMC Apache OpenOffice
http://es.openoffice.org |
|
| Back to top |
|
 |
squenson Super User


Joined: 09 Mar 2007 Posts: 690 Location: Nis, Serbia
|
Posted: Sat Jun 09, 2007 12:27 am Post subject: |
|
|
JZA,
You cannot select a row as such, but yo can select all the cells of row 23 with | Code: | | oMyCurrentRange = oSheet.getCellRangeByName("A23:IV23") | And then apply the background color you want.
But there are simpler options without a macro to highlight every other row. For example, create a new style, called blue, and give it a blue background, then use a conditional formatting that assigns the blue style for each cell in your entire range: _________________ Help us to help you: Add [Solved] to the title of the thread if you agree with the answer
>>> Do you know the new OOo support forum http://user.services.openoffice.org/en/forum/index.php? <<< |
|
| Back to top |
|
 |
JZA OOo Advocate


Joined: 01 Feb 2003 Posts: 432 Location: Mexico
|
Posted: Sat Jun 09, 2007 1:32 am Post subject: |
|
|
I most be doing something wrong I went ahead with the conditional formating however it didnt quite work. What did the MOD(ROW();2)=1 was supposed to go. What does MOD() means, since I am using a spanish version of OOo I need to know the function to find it on the function list.
I did found ROW() btw.
Is this supposed to go on the field for the different conditionals? Thanks. _________________ Alexandro Colorado
PPMC Apache OpenOffice
http://es.openoffice.org |
|
| Back to top |
|
 |
squenson Super User


Joined: 09 Mar 2007 Posts: 690 Location: Nis, Serbia
|
Posted: Sat Jun 09, 2007 1:46 am Post subject: |
|
|
JZA,
MOD(x, y) returns the remainder after a number x is divided by a divisor y. So, depending on the value of the row number, the formula returns either 0 or 1.
Select your range, then use the menu Format > Conditional formatting
Select Formula is (or Spanish equivalent) is the first combo box, which hides the second combobox and in the text field area put the formula MOD(ROW();2)=1, then select the proper style if the condition is true. _________________ Help us to help you: Add [Solved] to the title of the thread if you agree with the answer
>>> Do you know the new OOo support forum http://user.services.openoffice.org/en/forum/index.php? <<< |
|
| Back to top |
|
 |
Villeroy Super User


Joined: 04 Oct 2004 Posts: 10065 Location: Germany
|
|
| Back to top |
|
 |
|