jeudi 29 octobre 2020

a vba code to improve If-function in excel

I am using functions like the following function in excel a lot.

=if(A1<>"",1/A1,"")

but I got tired of writing the (A1<>"") part because there is lots of cells which I should check if they are empty or not. so I was thinking if I can write a vba code like " If " which gets some formula as input and then check for me if all the cells included in the formula have some conditions (like there is a number there or not, being zero and so on) then it saves me lots of time and also my formulas inserted are much more readable.but unfortunately I don't know how to get the formula as an input and how to look at the cells included in the formula. so, myfunction should be like this

=myfun(1/A1)

and then it checks for me if A1 is empty so it don't give me any result.

Aucun commentaire:

Enregistrer un commentaire