Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Can a custom worksheet function written in VBA perform the same types of actions as a subroutine?

0
10 Posted

Can a custom worksheet function written in VBA perform the same types of actions as a subroutine?

0
10

No. Functions called from a worksheet formula have some limitations. In general, they must be strictly “passive” — they can t change the active cell, apply formatting, open workbooks, change the active sheet, and so on. Functions can only perform calculations and return a value. An exception to this rule is the VBA MsgBox function. A custom function can display a MsgBox whenever it is recalculated. This is very handy for debugging a custom function. I would like to create a function or subroutine that automatically changes the formatting of a cell based on the data I enter. For example, if I enter a value greater than 0, the cell’s background color should be red. Is this possible? It’s certainly possible, and you don’t need any programming. Use Excel’s Conditional Formatting feature, accessed with the Format – Conditional Formatting command. The Conditional Formatting features is useful, but I’d like to perform other types of operations when data is entered into a cell. In that case,

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123