ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   How can I embed a macro into a function in excel? (https://www.excelbanter.com/excel-worksheet-functions/10336-how-can-i-embed-macro-into-function-excel.html)

Don

How can I embed a macro into a function in excel?
 
I'm trying to create a logical "if" statment that will turn a cell one color
or another depending on what is in another cell. How does one insert/trigger
a macro in a function?

JE McGimpsey

Try using Conditional Formatting instead.

Select A1. Choose Format/Conditional Formatting. Enter

CF1: Formula is =A210
Format1: Patterns/Red

Click OK.

Now when you enter a value 10 in A2, cell A1 turns red.

If you need more than 3 conditional colors, you'll have to use an event
macro, such as a Worksheet_Calculate or Worksheet_Change:

http://cpearson.com/excel/events.htm


In article ,
Don wrote:

I'm trying to create a logical "if" statment that will turn a cell one color
or another depending on what is in another cell. How does one insert/trigger
a macro in a function?


Gord Dibben

Don

Investigate the use of FormatConditional Formatting. Allows 3 conditions(4
if you count the default)

You could use the Formula is:

e.g.

condition 1 =A1="qwerty" format to blue color.

Add and condition 2 =A1123 format to red color.

Add and condition 3 =A1=123 format to green color.

Functions cannot call macros.


Gord Dibben Excel MVP

On Thu, 27 Jan 2005 14:39:01 -0800, Don wrote:

I'm trying to create a logical "if" statment that will turn a cell one color
or another depending on what is in another cell. How does one insert/trigger
a macro in a function?




All times are GMT +1. The time now is 01:52 AM.

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