PC Review


Reply
Thread Tools Rate Thread

Cell Background Color Change --> Change Event

 
 
mark
Guest
Posts: n/a
 
      6th Jan 2009

Hello.

A user wants to sum value based upon cell color background.

I gave her a custom function to do thatm, based upon this:
>>>>>>>>>

Function CellColorIndex(InRange As Range) As Integer

' This function returns the ColorIndex value of the Interior (background) of
a cell

Application.Volatile True

CellColorIndex = InRange.Interior.ColorIndex

End Function
>>>>>>>>>>>


But, when she changes the cell color, this function is not recalculating,
unless she specifically tells it to.

I tried putting an Activesheet.usedrange.calculate into the worksheet's
change event, but it appears that a change in a cell's background color
format, does not fire the worksheet change event.

Can someone suggest a good way to make this dynamic, based upon the current
cell color?

Thanks.
Mark

 
Reply With Quote
 
 
 
 
JLGWhiz
Guest
Posts: n/a
 
      7th Jan 2009
There is no Format change event.

"mark" wrote:

> Hello.
>
> A user wants to sum value based upon cell color background.
>
> I gave her a custom function to do thatm, based upon this:
> >>>>>>>>>

> Function CellColorIndex(InRange As Range) As Integer
>
> ' This function returns the ColorIndex value of the Interior (background) of
> a cell
>
> Application.Volatile True
>
> CellColorIndex = InRange.Interior.ColorIndex
>
> End Function
> >>>>>>>>>>>

>
> But, when she changes the cell color, this function is not recalculating,
> unless she specifically tells it to.
>
> I tried putting an Activesheet.usedrange.calculate into the worksheet's
> change event, but it appears that a change in a cell's background color
> format, does not fire the worksheet change event.
>
> Can someone suggest a good way to make this dynamic, based upon the current
> cell color?
>
> Thanks.
> Mark
>

 
Reply With Quote
 
JLGWhiz
Guest
Posts: n/a
 
      7th Jan 2009
Sorry to cut that so short. Had an emergency.
Like I said, there is no Format change event, but you might use the
worksheet_selectionchange event to trigger the macro.

"mark" wrote:

> Hello.
>
> A user wants to sum value based upon cell color background.
>
> I gave her a custom function to do thatm, based upon this:
> >>>>>>>>>

> Function CellColorIndex(InRange As Range) As Integer
>
> ' This function returns the ColorIndex value of the Interior (background) of
> a cell
>
> Application.Volatile True
>
> CellColorIndex = InRange.Interior.ColorIndex
>
> End Function
> >>>>>>>>>>>

>
> But, when she changes the cell color, this function is not recalculating,
> unless she specifically tells it to.
>
> I tried putting an Activesheet.usedrange.calculate into the worksheet's
> change event, but it appears that a change in a cell's background color
> format, does not fire the worksheet change event.
>
> Can someone suggest a good way to make this dynamic, based upon the current
> cell color?
>
> Thanks.
> Mark
>

 
Reply With Quote
 
Shane Devenshire
Guest
Posts: n/a
 
      7th Jan 2009
Hi,

probably you should trigger the Worksheets(1).Calculate command inside an
Change event:

Here is some sample code:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim isect As Range
Set isect = Application.Intersect(Target, Range("A1"))
If Not isect Is Nothing Then
'Your code here
End If
End Sub

If this helps, please click the Yes button.

Cheers,
Shane Devenshire

"mark" <(E-Mail Removed)> wrote in message
news:9D4293C6-7842-46AF-9D39-(E-Mail Removed)...
> Hello.
>
> A user wants to sum value based upon cell color background.
>
> I gave her a custom function to do thatm, based upon this:
>>>>>>>>>>

> Function CellColorIndex(InRange As Range) As Integer
>
> ' This function returns the ColorIndex value of the Interior (background)
> of
> a cell
>
> Application.Volatile True
>
> CellColorIndex = InRange.Interior.ColorIndex
>
> End Function
>>>>>>>>>>>>

>
> But, when she changes the cell color, this function is not recalculating,
> unless she specifically tells it to.
>
> I tried putting an Activesheet.usedrange.calculate into the worksheet's
> change event, but it appears that a change in a cell's background color
> format, does not fire the worksheet change event.
>
> Can someone suggest a good way to make this dynamic, based upon the
> current
> cell color?
>
> Thanks.
> Mark
>

 
Reply With Quote
 
mark
Guest
Posts: n/a
 
      7th Jan 2009
but, like I said, and JLGWhiz confirmed, changing the background color
doesn't fire the worksheet_change event.

so, placing a worksheets(1).calculate command inside a worksheet_change
event, isn't going to do anything.

It sounds like JLGWhiz's suggestion to cause it to calculate upon a
selection change, is the closest that's possible.

"Shane Devenshire" wrote:

> Hi,
>
> probably you should trigger the Worksheets(1).Calculate command inside an
> Change event:
>
> Here is some sample code:
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> Dim isect As Range
> Set isect = Application.Intersect(Target, Range("A1"))
> If Not isect Is Nothing Then
> 'Your code here
> End If
> End Sub
>
> If this helps, please click the Yes button.
>
> Cheers,
> Shane Devenshire
>
> "mark" <(E-Mail Removed)> wrote in message
> news:9D4293C6-7842-46AF-9D39-(E-Mail Removed)...
> > Hello.
> >
> > A user wants to sum value based upon cell color background.
> >
> > I gave her a custom function to do thatm, based upon this:
> >>>>>>>>>>

> > Function CellColorIndex(InRange As Range) As Integer
> >
> > ' This function returns the ColorIndex value of the Interior (background)
> > of
> > a cell
> >
> > Application.Volatile True
> >
> > CellColorIndex = InRange.Interior.ColorIndex
> >
> > End Function
> >>>>>>>>>>>>

> >
> > But, when she changes the cell color, this function is not recalculating,
> > unless she specifically tells it to.
> >
> > I tried putting an Activesheet.usedrange.calculate into the worksheet's
> > change event, but it appears that a change in a cell's background color
> > format, does not fire the worksheet change event.
> >
> > Can someone suggest a good way to make this dynamic, based upon the
> > current
> > cell color?
> >
> > Thanks.
> > Mark
> >

>

 
Reply With Quote
 
mark
Guest
Posts: n/a
 
      7th Jan 2009
Thanks for the suggestion... too bad this isn't more directly available.

Lotus 5.0 had an internal function that woud read cell color. (I know Lotus
5.0 was pre Win95, and way out of date now, but it did have some nice stuff
for it's time)

"JLGWhiz" wrote:

> Sorry to cut that so short. Had an emergency.
> Like I said, there is no Format change event, but you might use the
> worksheet_selectionchange event to trigger the macro.
>
> "mark" wrote:
>
> > Hello.
> >
> > A user wants to sum value based upon cell color background.
> >
> > I gave her a custom function to do thatm, based upon this:
> > >>>>>>>>>

> > Function CellColorIndex(InRange As Range) As Integer
> >
> > ' This function returns the ColorIndex value of the Interior (background) of
> > a cell
> >
> > Application.Volatile True
> >
> > CellColorIndex = InRange.Interior.ColorIndex
> >
> > End Function
> > >>>>>>>>>>>

> >
> > But, when she changes the cell color, this function is not recalculating,
> > unless she specifically tells it to.
> >
> > I tried putting an Activesheet.usedrange.calculate into the worksheet's
> > change event, but it appears that a change in a cell's background color
> > format, does not fire the worksheet change event.
> >
> > Can someone suggest a good way to make this dynamic, based upon the current
> > cell color?
> >
> > Thanks.
> > Mark
> >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
change background color of cell as value changes S Himmelrich Microsoft Excel Programming 4 15th Jan 2008 09:18 PM
change background row color with change of date in a cell =?Utf-8?B?VXJzenVsYQ==?= Microsoft Excel Misc 5 17th May 2006 07:56 AM
background color of my cell does not change =?Utf-8?B?Q29sb3JibGluZGVk?= Microsoft Excel Misc 2 27th Mar 2005 04:55 PM
I need the formula to change the background color in one cell bas. =?Utf-8?B?d2lsbG93c3dhbg==?= Microsoft Excel Worksheet Functions 2 17th Sep 2004 07:35 AM
Change background color in a cell. gio123bg Microsoft Excel Discussion 2 14th Jan 2004 02:00 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:04 PM.