ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   How do I test a cell's formula (ex: Is this cell and Avg or a sum? (https://www.excelbanter.com/excel-worksheet-functions/214703-how-do-i-test-cells-formula-ex-cell-avg-sum.html)

Karie

How do I test a cell's formula (ex: Is this cell and Avg or a sum?
 
I want to be able to test the formula for a cell to see if it is an Average
or a Sum.

EX: ( if the first 4 characters of the forumula for A:3 = "=AVG", then B:3 =
"Average")

If not, can I designate cells by color. Then test for all cells that are a
certain color...

EX: (if Color of A:3 is red, then B:3 equals "Average")





JE McGimpsey

How do I test a cell's formula (ex: Is this cell and Avg or a sum?
 
One way:

-Select Cell B1.
-Choose Insert/Name/Define
-Enter in 'Names in workbook:" box:

FormulaToLeft

-Enter in 'Refers to:' box:

=Get.Formula(A1)

-Click Add, OK

-in cell b3, enter:

=IF(ISERR(FIND("AVERAGE(",FormulaToLeft)),"","Aver age")

Or, to differentiate between AVERAGE and SUM:
=IF(ISERR(FIND("AVERAGE",FormulaToLeft)),
IF(ISERR(FIND("SUM(",FormulaToLeft)), "Neither","SUM"), "Average")

NOTE: Copying worksheets with references to XL4M commands (such as
Get.Formula()) to a new workbook will crash MacXL and Pre-WinXL03
applications.



In article ,
Karie wrote:

I want to be able to test the formula for a cell to see if it is an Average
or a Sum.

EX: ( if the first 4 characters of the forumula for A:3 = "=AVG", then B:3 =
"Average")

If not, can I designate cells by color. Then test for all cells that are a
certain color...

EX: (if Color of A:3 is red, then B:3 equals "Average")



All times are GMT +1. The time now is 12:58 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com