Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-31-2011, 11:46 PM
Catalin.B Catalin.B is offline What IF statement required Windows Vista What IF statement required Office 2007
Expert
 
Join Date: May 2011
Location: Iaşi, România
Posts: 386
Catalin.B is on a distinguished road
Default

May i sugest using a User Defined Function, to get cell or font color, as in example attached, then use this new functions in your formulas.
Attached Files
File Type: xlsm example.xlsm (18.1 KB, 10 views)
Reply With Quote
  #2  
Old 09-01-2011, 12:01 AM
dr4ke dr4ke is offline What IF statement required Windows XP What IF statement required Office 2007
Novice
What IF statement required
 
Join Date: Mar 2011
Posts: 8
dr4ke is on a distinguished road
Default

Quote:
Originally Posted by Catalin.B View Post
May i sugest using a User Defined Function, to get cell or font color, as in example attached, then use this new functions in your formulas.
Thank you for your response and the example, however i'm not amazingly technical with Excel and the forumla's have confused me a little bit. Could you perhaps explain what you have done so I could adapt it to my spreadsheet?

Thanks in advance,
Dr4ke
Reply With Quote
  #3  
Old 09-01-2011, 12:29 AM
Catalin.B Catalin.B is offline What IF statement required Windows Vista What IF statement required Office 2007
Expert
 
Join Date: May 2011
Location: Iaşi, România
Posts: 386
Catalin.B is on a distinguished road
Default

in the new attached example, in columns K and L, i used the UDF to get the cell color.
=IFERROR(IF(SEARCH("Person 1";C6)>0;SUMIFBYCOLOR(D6:E6;3;D6:E6;FALSE);0);0)-this formula in column G searches first cell for "Person 1" and sums the green range if the cell colour is 3 (means red to excel) all results are totalised in cell G6 for person 1.
Same for person 2 in column H...

This formula in cell J2:
=COUNTIFS(C$6:C$20;C$6;L$6:L$20;"=3")+COUNTIFS(C$6:C$20;C$6;K$6:K$20;"=3")
counts how many cells are red (=3) for C$6 (person 1), (depending to ranges L$6:L$20 and K$6:K$20)

This formula in cell J3:
=COUNTIFS(C$6:C$20;C$7;L$6:L$20;"=3")+COUNTIFS(C$6:C$20;C$7;K$6:K$20;"=3")
counts how many cells are red (=3) for C$7 (person 2), (depending to ranges L$6:L$20 and K$6:K$20). In the example, the result is 0, because there are no red cells for person 2...
but if you change =3 to =43, in J3 formula, you will get the number of cells that are color 43 for person 2... and so on, ....

This formula will get the cell color:
=CELLCOLORINDEX(D6;FALSE)
This formula will get the font color used in that cell:
=CELLCOLORINDEX(D6;TRUE)

NOTE: When you change the background or font color of a cell, Excel does not consider this to be changing the value of the cell. Therefore, it will not recalculate the worksheet, nor will it trigger a Worksheet_Change event procedure. This means that the values returned by these functions may not be correct immediately after you change the color of a cell. They will not return an updated value until you recalculate the worksheet by pressing ALT+F9 or by changing the actual value of a cell.
NOTE: These functions will not detect colors that are applied by Conditional Formatting.


If you want to use a UDF in more than one workbook, you can save your functions in your own custom add-in. Simply save your excel file that contains your VBA functions as an add-in file (.xla). Then load the add-in (Tools > Add-Ins...). Warning! Be careful about using custom functions in spreadsheets that you need to share with others. If they don't have your add-in, the functions will not work when they use the spreadsheet.
Attached Files
File Type: xlsm example.xlsm (19.0 KB, 13 views)
Reply With Quote
  #4  
Old 09-01-2011, 05:37 AM
OTPM OTPM is offline What IF statement required Windows 7 32bit What IF statement required Office 2010 32bit
Expert
 
Join Date: Apr 2011
Location: West Midlands
Posts: 981
OTPM is on a distinguished road
Default

Hi Catalin
I have looked at this solution using Excel 2010 in order to build on my own knowledge. However as soon as I enable the worksheet all the formulae fail to work and I get #NAME errors in Columns J, K and L, and 00:00:00 in Columns G and H.
Presumably this is because the Function VBA code is not contained in the spreadsheet sample you provided?
Please advise.
Thanks
Tony(OTPM)
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
What IF statement required Help with IF Statement limpbizkit Excel 4 02-24-2011 09:16 PM
Invoice Statement Shoshana3 Word 0 11-15-2010 03:02 PM
What IF statement required if statement piper7971 PowerPoint 1 08-19-2010 07:10 AM
What IF statement required Help with IF statement! CPelkey Word 1 04-12-2010 09:06 AM
Have you seen this error statement? nebb Word 4 12-01-2009 10:05 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:09 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft