Logo
Home >

The Existential Formula

2. December 2011

It's almost as if a formula is having doubts about its very existence.

Now, before you guys begin to doubt if I've had a couple too many, I'll explain myself. I got asked by a fried if Excel has a formula that identifies if a particula cell has a formula in it.

In other words, let's say you want to check if cell A1 has a formula in it. So you should, hypothetically speaking, be able to enter a formula like "=CHECKFORMULA(A1)" in A2, and if there does happen to a formula entered for Cell A1, it should return the value "TRUE". And if not, "FALSE". If you see what I mean.

Seemed simple enough, and although I hadn't come across such a formula myself, I was fairly sure that such a formula would exist within Excel's vast repertoire. But as I began to search through them, a sinking realization dawned on me... there's no such formula!

Which led me to look online for a solution, of course, and as it turns out, there happens to be a rather simple solution, although it does involve the use of macros.

Now, people generally react to even a casual mention of the word macro in much the same fashion as they react to algebra, Collaterized Debt Obligations and the Great White Shark: a neatly balanced mixture of fear and loathing. But worry not: in today's tutorial, we'll guide you through a drop-dead simple way of creating a custom formula in Excel.

Now, first things first: credit where credit's due. The solution was provided on a Yahoo forum by a lady called Anna M (thanks, Anna!), and we're just going to describe it in greater detail.

So here we go:

First, open fire up Excel, and hit ALT+F11 on your keyboard. That should open up your VBA editor. As Douglas Adams might have said, "Don't Panic!" It's just another window, and that's all there is to it!

Up at the very top, look for Insert, and click on it:

 

 

Choose Modules:

 

And in the new window, simply paste the code exactly as it appears below in the main window:

Function IsFormula(c)
IsFormula = c.HasFormula
End Function

 

And you don't even have to save the file! Simply close the window, and you're all set! You have just created a user developed formula... congratulations!

Now, to check if it actually works:

In the spreadsheet, enter any old formula in any old cell. Let's say, 3+4 in cell B3:

 

And in cell C3, type in our very own secret sauce recipe:

 

Now, upon hitting Enter, we should get to see that magic grouping of letters: TRUE

...and voila!

 

As simple as all that! Now, you'll probably have to do this every time you fire up Excel, and your macro security settings might need a little tweaking, but nothing out of the ordinary, I promise you. All in all, if you do this right (and it is simple to do, I'm sure you'll agree), you should have this custom formula up and running in no time.

As always, if you know of a simple way to do this, send your emails/comments in right away, and we'll put 'em up ASAP!

Bookmark and Share

Powered by Olark