ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   how do I change the fill collor os a cell using a function in VB (https://www.excelbanter.com/excel-discussion-misc-queries/67847-how-do-i-change-fill-collor-os-cell-using-function-vbulletin.html)

Jason R Morris

how do I change the fill collor os a cell using a function in VB
 
I am trying to us an if then statment in a function to change the fill color
of a cell if the conditions are true. I have tried
"ActiveCell.Interior.ColorIndex = 6" that works in subs, but it does not
works in functions.

Norman Jones

how do I change the fill collor os a cell using a function in VB
 
Hi Jason,

A user defined function (UDF) returns a value; it cannot change formatting
or alter its environment


---
Regards,
Norman



"Jason R Morris" wrote in message
...
I am trying to us an if then statment in a function to change the fill
color
of a cell if the conditions are true. I have tried
"ActiveCell.Interior.ColorIndex = 6" that works in subs, but it does not
works in functions.




BekkiM

how do I change the fill collor os a cell using a function in VB
 
Why not just use conditional formatting? You can set up essentially the same
If/then conditions and get your fill color that way.

"Jason R Morris" wrote:

I am trying to us an if then statment in a function to change the fill color
of a cell if the conditions are true. I have tried
"ActiveCell.Interior.ColorIndex = 6" that works in subs, but it does not
works in functions.


David McRitchie

how do I change the fill collor os a cell using a function in VB
 
see Conditional Formatting
http://www.mvps.org/dmcritchie/excel/condfmt.htm
---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"BekkiM" wrote...
Why not just use conditional formatting? You can set up essentially the same
If/then conditions and get your fill color that way.

"Jason R Morris" wrote:
I am trying to us an if then statment in a function to change the fill color
of a cell if the conditions are true. I have tried
"ActiveCell.Interior.ColorIndex = 6" that works in subs, but it does not
works in functions.





All times are GMT +1. The time now is 09:53 AM.

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