If function using cell format as the condition

I would like to create an "If" logical function formula, where the "true" 
condition is based on the format of the cell.

For instance, if cell b3 is formatting with a fill color, then add that 
number; if not, then add zero.

Can anyone help?
0
Utf
12/9/2009 2:21:01 AM
excel.worksheet.functions 4936 articles. 2 followers. Follow

3 Replies
1120 Views

Similar Articles

[PageSpeed] 26

That will need VBA, unless the fill colour is derived from conditional 
formatting (in which case you could impose an equivalent condition).
--
David Biddulph

"Janie" <Janie@discussions.microsoft.com> wrote in message 
news:25499DED-25B8-4E7D-8CA2-A22788839E56@microsoft.com...
>I would like to create an "If" logical function formula, where the "true"
> condition is based on the format of the cell.
>
> For instance, if cell b3 is formatting with a fill color, then add that
> number; if not, then add zero.
>
> Can anyone help? 


0
David
12/9/2009 3:09:19 AM
There is no built-in excel function to do this. But you can use a UDF that 
looks at the range and returns the sum of color.  But that function will not 
recalculate if you change color.  Every time you change the color you will 
need to recalculate or wait excel to recalculate...

To install the UDF (User Defined function). From workbook launch VBE using 
Alt+F11. From menu Insert a Module and paste the below function.Close and get 
back to workbook and try the below formula.

=colorsum(A5:A9,D5)
cell D5 will have the fill color which is the query color...to be searched 
in the range A5:A9

'If you mean to sum the cell values with matching color then
Function ColorSum(varRange As Range, varColor As Range)
Dim arrTemp As Variant, varTemp As Variant
For Each cell In varRange
varTemp = cell.Interior.ColorIndex
If varTemp = varColor.Interior.ColorIndex Then ColorSum = ColorSum + 
cell.Value
Next
End Function

-- 
Jacob


"Janie" wrote:

> I would like to create an "If" logical function formula, where the "true" 
> condition is based on the format of the cell.
> 
> For instance, if cell b3 is formatting with a fill color, then add that 
> number; if not, then add zero.
> 
> Can anyone help?
0
Utf
12/9/2009 7:15:01 AM
Use the below code instead....(the previous one might give you syntax issues 
due to text alignment)

'If you mean to sum the cell values with matching color then
Function ColorSum(varRange As Range, varColor As Range)
Dim arrTemp As Variant, varTemp As Variant
For Each cell In varRange
varTemp = cell.Interior.ColorIndex
If varTemp = varColor.Interior.ColorIndex Then 
ColorSum = ColorSum + cell.Value
End If
Next
End Function

-- 
Jacob


"Jacob Skaria" wrote:

> There is no built-in excel function to do this. But you can use a UDF that 
> looks at the range and returns the sum of color.  But that function will not 
> recalculate if you change color.  Every time you change the color you will 
> need to recalculate or wait excel to recalculate...
> 
> To install the UDF (User Defined function). From workbook launch VBE using 
> Alt+F11. From menu Insert a Module and paste the below function.Close and get 
> back to workbook and try the below formula.
> 
> =colorsum(A5:A9,D5)
> cell D5 will have the fill color which is the query color...to be searched 
> in the range A5:A9
> 
> 'If you mean to sum the cell values with matching color then
> Function ColorSum(varRange As Range, varColor As Range)
> Dim arrTemp As Variant, varTemp As Variant
> For Each cell In varRange
> varTemp = cell.Interior.ColorIndex
> If varTemp = varColor.Interior.ColorIndex Then ColorSum = ColorSum + 
> cell.Value
> Next
> End Function
> 
> -- 
> Jacob
> 
> 
> "Janie" wrote:
> 
> > I would like to create an "If" logical function formula, where the "true" 
> > condition is based on the format of the cell.
> > 
> > For instance, if cell b3 is formatting with a fill color, then add that 
> > number; if not, then add zero.
> > 
> > Can anyone help?
0
Utf
12/9/2009 7:20:01 AM
Reply:

Similar Artilces:

Converting Text to an external cell ref.
Hi, I'm, trying to put together an external cell reference in my worksheet. I can join together text that looks like the File Path / Work Sheet / Cell reference, but I can't figure out how to turn this string of text into a file path etc. and pick up the data I want. I get this strange feeling I'm being a complete idiot asking this can't see the wood for the trees, but I need help. --- Message posted from http://www.ExcelForum.com/ Hi normally you can use INDIRECT for this. E.g. =INDIRECT("'[Book1.xls]Sheet1'!A1") which gets the value from cell A1, sheet...

Can formulas in cells be made to remain if the data is deleted?
Can you explain in a bit more detail what your question/problem is? -- Kind regards, Niek Otten "wendyp" <wendyp@discussions.microsoft.com> wrote in message news:B7A92B0A-E752-4D58-90FF-3DE5F292D35C@microsoft.com... > Hi Wendy, See Insert a Row using a Macro to maintain formulas http://www.mvps.org/dmcritchie/excel/insrtrow.htm To simply remove constants from a selection within a macro Selection. SpecialCells(xlConstants).ClearContents To remove constants manually from a selection Edit, GoTo (Ctrl+G), Constans [you can pick what kind ...

Copying Text to Clip Board Using a Macro
Hi, is it possible to store text e.g. a standard script which I constantly use within the code of a macro ? The macro would be assigned to a button and when the button is �clicked on� it would copy this text to the clip board which will then allow me to paste it into another application. Currently this text is stored in a cell and I reference this cell and copy to clip board this way, buy I want to get away from storing text this way. Any help would be grateful appreciates Many thanks Rob -- robertguy 44 Married two kids ------------------------------------------------------------...

ROUND Function with other function
Hi, I have this formula: =IF(R8>0,CONCATENATE("+",R8),R8) and the results shows me for example: +11.6 but what I really want t show is +12. I've been trying to put the "Round" function at a few places in th formula but it doesn't work. The closest I got was with this formula: =ROUND(IF(R8>0,CONCATENATE("+",R8),R8),0) where it showed me 12, without the "+" sign before.... Can anyone help me ? Thank -- Outapi ----------------------------------------------------------------------- Outapin's Profile: http://www.excelforum.com/member...

Show actual values added instead of cell references? (=A1+A4 shows as =10+2 in cell)
Is this even possible? I have the following: A1 =A2 (Shows result of 10) A2 10 A3 A4 =A5 (Shows Result of 2) A5 2 A7 =10+2 (Shows result of 27) Is there a way to show the formula in A7 as =10+2 instead of having it =A2+A5 ??? Thanks a bunch! On Dec 29, 1:24=A0pm, Naji <najisaa...@gmail.com> wrote: > Is this even possible? > > I have the following: > > A1 =A0=3DA2 (Shows result of 10) > A2 =A010 > A3 > A4 =3DA5 (Shows Result of 2) > A5 2 > > A7 =3D10+2 (Shows result of 27) > > Is there a way to show the formula in A7...

Returning a range from an inner function
I have a range of data, which has had the DOLLAR() function performed on it. I would like to get the total of this range using the SUM() function. doing SUM(F1:F4) will not work, so I need to convert the data into values that will work. The VALUE() function is perfect for converting the data into values that will work for SUM(), but the formula SUM(VALUE(F1:F4)) does not work because VALUE() will not accept a range as a parameter (and also does not return a range). I need to perform the VALUE() function on each cell before submitting it to SUM(). There must be some way to do this, cons...

Can a Formula in Cell X modify Cell Y?
Example: A Formula in Cell A1 should do the following: If cell A1 equals 1, then cell B1 should have the value 5, otherwise B1 should be 6. A condition in cell A1 is changing the value of cell B1... is that possible? Please note that there is NO Formular in Cell B1, which is the cell to be modified... Thanks No, only through VBA -- Regards, Peo Sjoblom "alMandragor" <alMandragor@discussions.microsoft.com> wrote in message news:94154F2A-DBD2-4A47-AF47-F21935C77B91@microsoft.com... > Example: > > A Formula in Cell A1 should do the following: > > If c...

JustifyString function problem
Hi, I'm using the "JustifyString" function (from Stephan Lebans) to right justify three columns in a ListBox. Two of them are working fine ... one's a simple number (long integer) and the other's currency. The third causes an Access 2003 crash! That third column is a long integer which is a link to the autonumber field in another table. Both tables are in the query as I need columns from both tables in the ListBox. If I change the JustifyString to reference the autonumber field in the other table, I still get an Access crash. I didn't review the Access er...

automating functions
I am a complete novice at CRM 1.2, but want to be able to create, for example, a workflow process that will monitor the CSR's and the queues and automatically assign a new case to the least busy CSR. Any input would be appreciated. Thanks in advance Jim Please tell me what I would have to do and with what tools in order to create such a workflow process. "jmb" wrote: > I am a complete novice at CRM 1.2, but want to be able to create, for > example, a workflow process that will monitor the CSR's and the queues and > automatically assign a new case to the lea...

Using a formulae within scenarios
Hi, I've just used scenarios for the first time but am a little frustrated in that it only remembers specific values rather than the actual cell reference that I type into the "Enter values for each of the changing cells" boxes. Is there a way of doing this as I wanted to include a whole range of values in the scenario that would be replaced each time. For example consider a basic cashflow forecast where line 1 is balance brought forward lines 2-5 are various incomes lines 6-8 are various payments line 9 is balance carry forward (sum of all of the above) each column represe...

Cell manipulation
I have a spreadsheet with 20 rows of data. The data is one cell in length and goes from cell A1 to A20. What I'm wondering is if there's a formula or function that I can use to take the data that is in cell A2 and move it to B1 and likwise down the list -- A3 to C1, A4 to D1. This 20 item list is a very small one. I'm going to be working with 200 items and larger and need to do the same thing. Any help is appreciated. Thanks, Kevin G copy. paste-special in a blank cell with transpose selected. >-----Original Message----- >I have a spreadsheet with 20 rows ...

Returning a CHAR[] from a function
I have the following function that returns the path of where the program was run from. However I cant seem to return the butter as a CHAR. The code works if I use it in a procedure but not where I need to return the variable CHAR buffer. char CAutoRunDlg::GetProgramPath(void) { char buffer[_MAX_PATH]; //declares maimum path //opens window maximized //_getcwd(,)gets the current working directory // #include <direct.h> //needed for current working directory /* Get the current working directory: */ if( _getcwd( buffer, _MAX_PATH ) == NULL ) perror( "_getcwd error" )...

comment format
How does one set the default comment format (font, etc)? I hope I will succeed in translation - as my OS UI is in Hebrew. * Right click on an empty place in your DeskTop > 'Properties...' * Click the View [or is it display] Tab > 'Advanced' * Open the "Item" Combo-box and scroll down and click the "Tool Description' > choose the font SIZE > OK > OK. *** I don't think that changing the font type and/or color will affect the Comments in Excel. *** Pay attention that this procedure will change all *** There is no problem to write...

Turning Off Error Reporting using API Functions and VB
We want to automatically turn off the error reporting options using Windows API functions for the following functions area Click on Start, Settings, Control Panel, System, the Advanced tab and Error Reporting (at the bottom of the screen), which launches the Error Reporting screen. Another way to get to that screen: Open My Computer, right-click on Properties, click on Advanced tab and Error Reporting. Any assistance would be welcome. It's not a program's call. It's the user's decision. --=20 -------------------------------------------------------------------------= --...

Complex functions
Hi All, Suppose you have a very complex and long function that is also subject to a condition, then you will/can have something like: =if(condition(complex function), complex function, other complex function) It can have more lines in the formula bar, so readability below 0 Kelvin. Is there a way to 'name' a function? =If(condition(myfunc = complex function), myfunc, other complex function) With kind regards, JP Yes you can put a formula into an Excel Name (the same as you can give a range an Excel Name. Very powerful it can be too. Do a Google fo...

How do I add a cell reference in a header?
I'm trying to add a cell reference in the header of an Excel document. The workbook allows a user to select choices from a drop-down menu and pulls the specific data into summaries, but I would also like the selection to change the header each time. Hi only possible with VBA using an event procedure. e.g. put the following code in your workbook module: Private Sub Workbook_BeforePrint(Cancel As Boolean) Dim wkSht As Worksheet For Each wkSht In Me.Worksheets With wkSht.PageSetup .CenterHeader = wkSht.range("A1").value End With Next wkSht End Sub -...

Match Function
Hi, I have put together a spreadsheet to find codes, states, descriptions. It finds the data by dates. Columns are: Dates, Codes, States, Descriptions If I put in a date it matches the code, state and description. My problem is that if I have 2 dates that are the same it will only match the first date it can find. What kind of formula do I need so that it will output the second or third date data. Thanks for your help. If you need a copy of the spreadsheet please let me know. How many rows of data do you have? -- Biff Microsoft Excel MVP "Melanie" <Melanie@discussio...

how to catch values from a texts to use it as values
Hi. I want to create a formula system in my access program. So I using a little funcionality that I already have in my system that make calcs using a prompt command. So, I'm trying to load a text value that as the formula: (([Field1]*[field2]*[field3]*[field4])/[field5]) but this don't work because the form cannot use the text values, it uses text, imagine this: I havee in this fields: field1: 10 field2: 30 field3: 2 field4: 14 field5: 12 I want that my value is: 700 My problem is that the form cannot understand that it should not use the text but the inside numbers. I also...

If Function Function
okay. So I am trying to workout a formula to compute a commision earning. Basically, if X amount of new business is made, then X*Y (corresponding Commision rate percentage), but if new business =<X, then X*Y (Commision rate percentage that is true). Problem is, it's super confusing...anyone have any suggestions? See if this helps: http://mcgimpsey.com/excel/variablerate.html -- Biff Microsoft Excel MVP "aetejada" <aetejada@discussions.microsoft.com> wrote in message news:AA4E55F7-9435-4BB6-837A-416A59BB72A0@microsoft.com... > okay. So I am...

Can faxs be sent to the user inbox while using POP3 connnector.
Can faxs be sent to the user inbox while using POP3 connnector instead of the full-blown exchange. Thanks On Thu, 13 Jul 2006 09:52:00 -0500, "john doe" <johndoe@johndoe.com> wrote: >Can faxs be sent to the user inbox while using POP3 connnector instead of >the full-blown exchange. > >Thanks > If the fax arrives as a message like an email, sure. Hi, In Outlook 2003, if a contact has a business fax, an entry will appear in the address book as email type FAX. Choosing this address and sending an email will be routed to our fax server. However, in OW...

Outlook 2002 Change Password function
I want users to be able to change password from the Outlook Login Page, but it does noet seem to work. Outlook 2002 Sp1 and Windows Server 2003 (AD) and Exchange 2003 SP1 Important: Outlook client is not member of the domain... There are not many Microsoft Articles about this. Anyone? -- Regards, Menko den Ouden Netherlands Menko den Ouden schreef in deze nieuwsgroep op 23-6-2005 15:28: > I want users to be able to change password from the Outlook Login Page, but > it does noet seem to work. > > Outlook 2002 Sp1 and Windows Server 2003 (AD) and Exchange 2003 SP1 > ...

DateDiff function throwing error in Where clause
I have a set of queries that generate dates and want to use DateDiff to select those records with certain dates are greater than others. The following clause keeps giving me an incompatible data type error: WHERE DateDiff('d',[From date],[DatumStvoreni])>0 I have the exact expression in the SELECT clause and it show positive and negative integers just fine, but when I add this test, I get the error. There are no bad values in the dataset, I've looked, and when I export the DateDiff column to a temp table and run a query on that, it works fine. Only when I use t...

How to Select Multiple Cells Conforming to A Certain Criteria Automatically?
Dear all, I have a big table containing a lot of data in my worksheet. Within a particular column, I want to select cells whose row numbers form an arithmetic progression with a common difference 8(e.g. G6, G14, G22, ...). At the moment, I can only perform this task by selecting the cells individually while pressing "Ctrl", however, due to the large number of data in the table, this work is very tedious. Does anyone know if there is an automatic way to select these cells? Thank you. Best wishes, Alex, This code can do the job for you. Sub SelectCells() Dim rng1 As Range ...

timing a function
Good Morning All, I've writen an MFC C++ application, under VC++6.0 . How can I check how much time it takes for a specific function to complete? I need to know how many miliseconds one of my function call takes. Thanks very much in advance, Dudu Arbel If your accuracy requirement is in ms - use GetTickCount. -- Regards, Nish [VC++ MVP] http://www.voidnish.com http://blog.voidnish.com "dududuil" <dududuil@discussions.microsoft.com> wrote in message news:C0167B90-33D2-4A4F-A73D-DC4EBEF81946@microsoft.com... > Good Morning All, > > I've writen an MFC C++ ...

non-functioning multiple Array formulas in a workbook
I have a workbook with used for forecasting. I use a template sheet for each forecast (all forecast sheets -54- are the same and contain sheet-level names). On each sheet I have a formula that counts the number of chargeable engagements (where the chargeable engagement is indicated by a "C" in the preceding column) and places the results in a cell with concatenated text. The 'chargeable designation' column is a named range. I can get the formula to work on only two of the worksheets. It can be any two sheets, but it will only work on two sheets maximum. I have tried a numbe...