Ask Your Question
1

sort by color

asked 2012-08-03 05:11:37 +0200

this post is marked as community wiki

This post is a wiki. Anyone with karma >750 is welcome to improve it.

updated 2012-08-03 05:11:37 +0200

spider gravatar image spider
1 1 2

Some of my cells have background color and I need to be able to sort by color, but cannot seem to find how to do that. All help appreciated.

delete close flag offensive retag edit

Comments

Is there any sort of dependency between cell background color and cell content (value)? Or, to put the question in another way: how is the background color determined?

tohuwawohu ( 2012-08-03 17:41:02 +0200 )edit

4 Answers

Sort by » oldest newest most voted
2

answered 2012-08-03 19:44:56 +0200

this post is marked as community wiki

This post is a wiki. Anyone with karma >750 is welcome to improve it.

updated 2013-01-29 15:06:08 +0200

qubit gravatar image qubit flag of United States
5693 3 48 41

Here's one way. Add a macro function that returns a cell's background color as a number. Add a new column filled with that function that addresses the target background-colored cells. Sort on the numbers in the new column (use Ctrl-Shift-F9 to recalculate all functions before sorting. Be sure to include Option/Formats in the sort)

The auxilliary column contains the formula =BGCOLOR(CELL("COL",A1),CELL("ROW",A1)) where A1 is the target cell.

function bgcolor(col,row)
  rem # Returns background color of addressed cell
  s=thiscomponent.getcurrentcontroller.sheets.getbyname("Sheet1")
  cell=s.getcellbyposition(col-1,row-1)
  bgcolor=cell.cellBackColor
end function
link delete flag offensive edit
1

answered 2013-03-26 10:48:45 +0200

this post is marked as community wiki

This post is a wiki. Anyone with karma >750 is welcome to improve it.

updated 2013-03-26 10:49:22 +0200

camel1cz gravatar image camel1cz
1 1 2

Same problem as @Nissim. To solve it replace first line:

s=thiscomponent.getcurrentcontroller.sheets.getbyname("Sheet1")

With:

s=ThisComponent.sheets.getbyname("Sheet1")

link delete flag offensive edit
0

answered 2013-03-08 22:45:45 +0200

this post is marked as community wiki

This post is a wiki. Anyone with karma >750 is welcome to improve it.

updated 2013-03-08 22:45:45 +0200

Funkyecat gravatar image Funkyecat
1

Instructions poor. Do you enter '=BGCOLOR(CELL("COL",A1),CELL("ROW",A1)) where A1 is the target cell." in another column and drag down

where do you enter the macro.

link delete flag offensive edit
0

answered 2012-10-04 03:06:25 +0200

this post is marked as community wiki

This post is a wiki. Anyone with karma >750 is welcome to improve it.

updated 2012-10-04 03:06:25 +0200

Nissim gravatar image Nissim
1

I got this error:

LibreOffice 3.5 BASIC runtime error: property or method not found: sheets.

link delete flag offensive edit

Login/Signup to Answer

Donate

LibreOffice is made available by volunteers around the globe, backed by a charitable Foundation. Please support our efforts: Your donation helps us to deliver a better product!

Question tools

Follow
1 follower

subscribe to rss feed

Stats

Asked: 2012-08-03 05:11:37 +0200

Seen: 518 times

Last updated: Mar 26