Excel User Defined Function: change the cell's color

前端 未结 6 1145
生来不讨喜
生来不讨喜 2020-12-11 11:10

I have a user defined function in Excel. It is called as a formula function from spreadsheet cells and works fine.

I\'d like the function to be able to change the ce

6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-11 11:49

    No, you cannot alter a cell's color using a Function(). You can, however, alter it in a Sub() routine.

    Simply write a Sub() that will run your function on the cells you wish it to be run on, then after each is run, put an If-statement to see if you want to color it based on the value it returns.

提交回复
热议问题