Format a Cell from within a defined function

kkjensen

Active Member
Joined
Jun 22, 2004
Messages
354
Hi there,

I've written my own little function to do some particular bits of math that I don't want to have to repeat over and over.

When I write the function into a cell (not using my defined function) I generally do a custom format like:

[Red][>2]">2";0.00

I don't want to have my defined function outputting the text ">2" since I want to be able to link to the cell from other functions. Is there a way to (in a defined function) change the format of a cell to "custom" and enter something? I know how to do this in a macro using Activecell.numberformat = "0.00" etc etc but this does not work in a defined function. :oops:
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Functions can only return values. They can't perform actions like formatting cells, as you have discovered.

So the answer is no.
 
Upvote 0
Thanks.

I was always a bit curious about the differences between functions and macros. I thought they were essentilaly the same thing but a macro only ran when you told it to and a function updated according to the changing value of the other cells or values it refers to.
 
Upvote 0

Forum statistics

Threads
1,214,264
Messages
6,118,561
Members
448,837
Latest member
Josephjet

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top