Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Bart Schouw
 
Posts: n/a
Default Excel should be able to give back the colorcode of a cell via celi

It would be great if you could get returned the colorcode of certain cell,
based on this new calculcations are possible. For example some of my turnover
is based on pre-sales, these cells have have a certain color. It would be
great if i could count the number of cells with this color.
  #4   Report Post  
Arvi Laanemets
 
Posts: n/a
Default

Hi

Use an UDF. Like this one

Public Function GetColor(MyCell As Range) As Variant
GetColor = MyCell.Interior.ColorIndex
End Function


Now, the formula
=GetColor(A1)
returns the color code for cell A1. But be aware that changing cell color
doesn't trigger recalculating (and making the function volatile doesn't help
here) - you have to do it manually (pressing F9) or to wait until
recalculation is triggered by some change in cell values.


--
When sending mail, use address arvil<attarkon.ee
Arvi Laanemets


"Bart Schouw" <Bart wrote in message
...
It would be great if you could get returned the colorcode of certain cell,
based on this new calculcations are possible. For example some of my

turnover
is based on pre-sales, these cells have have a certain color. It would be
great if i could count the number of cells with this color.



  #5   Report Post  
JulieD
 
Posts: n/a
Default

Hi Bart

you're welcome ... Chip has lots of great stuff on his website - my other
favourite is Debra Dalgleish's at www.contextures.com/tiptech.html

more great sites are listed at www.mvps.org - under "Excel" on the right
hand side of the screen (unless they've redesigned their site again!) and a
bit of a google search will turn up a number of lists of good excel sites.

Cheers
JulieD

"Bart Schouw" wrote in message
...
Julie, this is exactly what I need, great stuff, thanks for the hint!
Cheers
Bart

"JulieD" wrote:

Hi Bart

check out
http://www.cpearson.com/excel/colors.htm
for things you can do with cell colours

Cheers
julieD

"Bart Schouw" <Bart wrote in message
...
It would be great if you could get returned the colorcode of certain
cell,
based on this new calculcations are possible. For example some of my
turnover
is based on pre-sales, these cells have have a certain color. It would
be
great if i could count the number of cells with this color.








  #6   Report Post  
Ola
 
Posts: n/a
Default

Hi,

Good simple solution Arvi.
=IF(NOW()0,GetColor(A1),"") will also recalculate.

Ola

  #7   Report Post  
Arvi Laanemets
 
Posts: n/a
Default

Hi


"Ola" wrote in message
...
Hi,

Good simple solution Arvi.
=IF(NOW()0,GetColor(A1),"") will also recalculate.



Did you test it?
Try it.
The function NOW() as any other function is recalculated only, when some
entry is changed. Cell color doesn't count as entry.

--
When sending mail, use address arvil<attarkon.ee
Arvi Laanemets


  #8   Report Post  
Ola
 
Posts: n/a
Default

Hi Arvi,

Your formula =getcolor(A10) will not recalculate by F9.
It will only recalculate if the actual cell change (F2+Enter, copy/paste).
On the other hand =IF(NOW()0,getcolor(A10),"") will recalculate by F9.
If I knew how, I would include cellcolor in morefunc.xll.

Ola

  #9   Report Post  
JE McGimpsey
 
Posts: n/a
Default

If you're going to make the overall function volatile anyway, wouldn't
it be more efficient to use

=GetColor(A10)

and put

Application.Volatile

in GetColor(), and avoid the extra function calls?

In article ,
Ola wrote:

Your formula =getcolor(A10) will not recalculate by F9.
It will only recalculate if the actual cell change (F2+Enter, copy/paste).
On the other hand =IF(NOW()0,getcolor(A10),"") will recalculate by F9.
If I knew how, I would include cellcolor in morefunc.xll.

  #10   Report Post  
 
Posts: n/a
Default

JE McGimpsey wrote...
If you're going to make the overall function volatile anyway, wouldn't


it be more efficient to use

=GetColor(A10)

and put

Application.Volatile

in GetColor(), and avoid the extra function calls?


This is a trade-off. If one puts Application.Volatile in the function,
then it's always volatile. If one only needs a few calls to be
effectively volatile, then that may be accomplished using Ola's trick,
though I prefer something like =f(x)+0*NOW() or =f(x)&LEFT(NOW(),0)
depending on what f() returns.



  #12   Report Post  
Arvi Laanemets
 
Posts: n/a
Default

Hi

You are right. I created it as volatile, tested it, and after that I decided
that the Volatile part is redundant and removed it - and forgot it. So the
function I tested was:

Public Function GetColor(MyCell As Range) As Variant
Application.Volatile
GetColor = MyCell.Interior.ColorIndex
End Function


Arvi Laanemets


"Arvi Laanemets" wrote in message
...
Hi


"Ola" wrote in message
...
Hi,

Good simple solution Arvi.
=IF(NOW()0,GetColor(A1),"") will also recalculate.



Did you test it?
Try it.
The function NOW() as any other function is recalculated only, when some
entry is changed. Cell color doesn't count as entry.

--
When sending mail, use address arvil<attarkon.ee
Arvi Laanemets




  #13   Report Post  
Wazooli
 
Posts: n/a
Default

I have inserted this code in my book.xlt, so it is always present. I know
nothing about VBA, so all this talk of volatility, etc... is completely not
understood by me. Is this code, as written, acceptable to be present in
large spreadhsheets? Will its presence have deleterious effects on
performance?

wazooli

"Arvi Laanemets" wrote:

Hi

Use an UDF. Like this one

Public Function GetColor(MyCell As Range) As Variant
GetColor = MyCell.Interior.ColorIndex
End Function


Now, the formula
=GetColor(A1)
returns the color code for cell A1. But be aware that changing cell color
doesn't trigger recalculating (and making the function volatile doesn't help
here) - you have to do it manually (pressing F9) or to wait until
recalculation is triggered by some change in cell values.


--
When sending mail, use address arvil<attarkon.ee
Arvi Laanemets


"Bart Schouw" <Bart wrote in message
...
It would be great if you could get returned the colorcode of certain cell,
based on this new calculcations are possible. For example some of my

turnover
is based on pre-sales, these cells have have a certain color. It would be
great if i could count the number of cells with this color.




  #14   Report Post  
Arvi Laanemets
 
Posts: n/a
Default

Hi


"Wazooli" wrote in message
...
I have inserted this code in my book.xlt, so it is always present. I know
nothing about VBA, so all this talk of volatility, etc... is completely

not
understood by me. Is this code, as written, acceptable to be present in
large spreadhsheets? Will its presence have deleterious effects on
performance?


When the UDF is volatile (contains code 'Application.Volatile' at start),
it's recalculated whenever any cell entry is changed, regardless there is a
need for it or not.
When the UDF isn't volatile, it's recalculated only, when it's argument(s)
do change. So my function posted here at start recalculates only, when the
value in cell (A1 in my example) the function refers to is changed. Ola's
improvement forces recalculation for particular cell, whenever any cell is
changed (because time always changes) - i.e. the function behaves as
volatile for this particular cell.

You can use this function, as any other UDF, in any workbook. It doesn't
matter, is the workbook large or not, but it matters in how much cells you
use it. This function MUST be always volatile (through code, or through
Ola's trick), and when you use it in too many cells, then the workbook will
be slowed down considerably. I don't see any other negative effects though.


Arvi Laanemets




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2003 FAILS, but Excel 2000 SUCCEEDS ??? Richard Excel Discussion (Misc queries) 2 May 13th 23 11:46 AM
Copy Word table into Excel cell by cell hg Excel Discussion (Misc queries) 3 December 15th 04 04:43 PM
Using Jet to read excel file returns blank for last cell - sometim Ron Excel Discussion (Misc queries) 1 December 9th 04 08:21 AM
Paste rows of numbers from Word into single Excel cell BecG Excel Discussion (Misc queries) 1 December 8th 04 04:55 PM
GET.CELL Biff Excel Worksheet Functions 2 November 24th 04 07:16 PM


All times are GMT +1. The time now is 02:53 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"