#1   Report Post  
DME
 
Posts: n/a
Default If Statement

Is there a way to produce an IF statemnt that relates to the Fill Color of a
Cel. For instance IF(the Fill Color of A1 = Red, then I want B2 * C2, IF
not then b2 *d2) .

I thought I saw something in this newsgroup beefore on this but I was unable
to find it.

Thanks in advance for help.


  #2   Report Post  
Bob Phillips
 
Posts: n/a
Default

You need a custom function for this. There is one at
http://www.xldynamic.com/source/xld.ColourCounter.html

--

HTH

RP
(remove nothere from the email address if mailing direct)


"DME" <craigjoseathotmaildotcom wrote in message
...
Is there a way to produce an IF statemnt that relates to the Fill Color of

a
Cel. For instance IF(the Fill Color of A1 = Red, then I want B2 * C2, IF
not then b2 *d2) .

I thought I saw something in this newsgroup beefore on this but I was

unable
to find it.

Thanks in advance for help.




  #3   Report Post  
Peo Sjoblom
 
Posts: n/a
Default

Not built in, but there are ways using VBA

http://www.cpearson.com/excel/colors.htm


Regards,

Peo Sjoblom

"DME" wrote:

Is there a way to produce an IF statemnt that relates to the Fill Color of a
Cel. For instance IF(the Fill Color of A1 = Red, then I want B2 * C2, IF
not then b2 *d2) .

I thought I saw something in this newsgroup beefore on this but I was unable
to find it.

Thanks in advance for help.



  #4   Report Post  
DME
 
Posts: n/a
Default

I opened a new workbook and went into VBA editor and entered the following
into this workbooks Microsoft Workbook Objects section:


Function CellColorIndex(InRange As Range, Optional _
OfText As Boolean = False) As Integer
'
' This function returns the ColorIndex value of a the Interior
' (background) of a cell, or, if OfText is true, of the Font in the cell.
'
Application.Volatile True
If OfText = True Then
CellColorIndex = InRange(1,1).Font.ColorIndex
Else
CellColorIndex = InRange(1,1).Interior.ColorIndex
End If

End Function

Then typed changed the font color of cell C8 to Red. And insert the
following formula in to D8:



=CELLCOLORINDEX(A1,FALSE)

The result is #Name?.



Any suggestions as to what I may have done wrong? Thanks.



"Peo Sjoblom" wrote in message
...
Not built in, but there are ways using VBA

http://www.cpearson.com/excel/colors.htm


Regards,

Peo Sjoblom

"DME" wrote:

Is there a way to produce an IF statemnt that relates to the Fill Color

of a
Cel. For instance IF(the Fill Color of A1 = Red, then I want B2 * C2,

IF
not then b2 *d2) .

I thought I saw something in this newsgroup beefore on this but I was

unable
to find it.

Thanks in advance for help.





  #5   Report Post  
DME
 
Posts: n/a
Default

Ooops, I meant to say I typed =CELLCOLORINDEX(C8,FALSE)

into cell D*.

"DME" <craigjoseathotmaildotcom wrote in message
...
I opened a new workbook and went into VBA editor and entered the following
into this workbooks Microsoft Workbook Objects section:


Function CellColorIndex(InRange As Range, Optional _
OfText As Boolean = False) As Integer
'
' This function returns the ColorIndex value of a the Interior
' (background) of a cell, or, if OfText is true, of the Font in the cell.
'
Application.Volatile True
If OfText = True Then
CellColorIndex = InRange(1,1).Font.ColorIndex
Else
CellColorIndex = InRange(1,1).Interior.ColorIndex
End If

End Function

Then typed changed the font color of cell C8 to Red. And insert the
following formula in to D8:



=CELLCOLORINDEX(A1,FALSE)

The result is #Name?.



Any suggestions as to what I may have done wrong? Thanks.



"Peo Sjoblom" wrote in message
...
Not built in, but there are ways using VBA

http://www.cpearson.com/excel/colors.htm


Regards,

Peo Sjoblom

"DME" wrote:

Is there a way to produce an IF statemnt that relates to the Fill

Color
of a
Cel. For instance IF(the Fill Color of A1 = Red, then I want B2 * C2,

IF
not then b2 *d2) .

I thought I saw something in this newsgroup beefore on this but I was

unable
to find it.

Thanks in advance for help.









  #6   Report Post  
Gord Dibben
 
Posts: n/a
Default

DME

Move the Function out of ThisWorkbook into a General Module.

InsertModule to create one.

Cut and paste the Function to that module.


Gord Dibben Excel MVP

On Tue, 25 Jan 2005 12:15:45 -0600, "DME" <craigjoseathotmaildotcom wrote:

I opened a new workbook and went into VBA editor and entered the following
into this workbooks Microsoft Workbook Objects section:


Function CellColorIndex(InRange As Range, Optional _
OfText As Boolean = False) As Integer
'
' This function returns the ColorIndex value of a the Interior
' (background) of a cell, or, if OfText is true, of the Font in the cell.
'
Application.Volatile True
If OfText = True Then
CellColorIndex = InRange(1,1).Font.ColorIndex
Else
CellColorIndex = InRange(1,1).Interior.ColorIndex
End If

End Function

Then typed changed the font color of cell C8 to Red. And insert the
following formula in to D8:



=CELLCOLORINDEX(A1,FALSE)

The result is #Name?.



Any suggestions as to what I may have done wrong? Thanks.



"Peo Sjoblom" wrote in message
...
Not built in, but there are ways using VBA

http://www.cpearson.com/excel/colors.htm


Regards,

Peo Sjoblom

"DME" wrote:

Is there a way to produce an IF statemnt that relates to the Fill Color

of a
Cel. For instance IF(the Fill Color of A1 = Red, then I want B2 * C2,

IF
not then b2 *d2) .

I thought I saw something in this newsgroup beefore on this but I was

unable
to find it.

Thanks in advance for help.





  #7   Report Post  
DME
 
Posts: n/a
Default

Thank You! It Works!!


"Gord Dibben" <gorddibbATshawDOTca wrote in message
...
DME

Move the Function out of ThisWorkbook into a General Module.

InsertModule to create one.

Cut and paste the Function to that module.


Gord Dibben Excel MVP

On Tue, 25 Jan 2005 12:15:45 -0600, "DME" <craigjoseathotmaildotcom

wrote:

I opened a new workbook and went into VBA editor and entered the

following
into this workbooks Microsoft Workbook Objects section:


Function CellColorIndex(InRange As Range, Optional _
OfText As Boolean = False) As Integer
'
' This function returns the ColorIndex value of a the Interior
' (background) of a cell, or, if OfText is true, of the Font in the cell.
'
Application.Volatile True
If OfText = True Then
CellColorIndex = InRange(1,1).Font.ColorIndex
Else
CellColorIndex = InRange(1,1).Interior.ColorIndex
End If

End Function

Then typed changed the font color of cell C8 to Red. And insert the
following formula in to D8:



=CELLCOLORINDEX(A1,FALSE)

The result is #Name?.



Any suggestions as to what I may have done wrong? Thanks.



"Peo Sjoblom" wrote in message
...
Not built in, but there are ways using VBA

http://www.cpearson.com/excel/colors.htm


Regards,

Peo Sjoblom

"DME" wrote:

Is there a way to produce an IF statemnt that relates to the Fill

Color
of a
Cel. For instance IF(the Fill Color of A1 = Red, then I want B2 *

C2,
IF
not then b2 *d2) .

I thought I saw something in this newsgroup beefore on this but I was

unable
to find it.

Thanks in advance for help.







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
IF Statement with Average Function results in #Value! Paul Excel Discussion (Misc queries) 5 December 28th 04 08:11 AM
7+ nested if statement? Turi Excel Worksheet Functions 3 December 20th 04 07:55 PM
Statement lintan Excel Worksheet Functions 1 December 2nd 04 11:31 PM
Duplicate fields does not match up! If statement Patsy Excel Worksheet Functions 0 November 11th 04 12:16 AM
IF Statement difficulty susan hayes Excel Worksheet Functions 3 November 2nd 04 09:46 PM


All times are GMT +1. The time now is 08:31 AM.

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

About Us

"It's about Microsoft Excel"