Excel – Can Excel 2013 show the formula instead of the value only in certain cells

microsoft excel

I need a specific column in my spreadsheet to show the formula and not the resulting value. It still needs to be seen by Excel as a formula but it just needs to show the formula in the cell and not the value. That means I can't convert the cell format to Text as Excel then doesn't see it as a formula. I also need this only for 1 column so toggling between showing formulas and showing results / values isn't an option either. So, as an example:

Cell B3 = 11/11/13 (a short date)
In cell F5 I put in =B3 and thus cell F5 shows 11/11/13.

I want cell F5 to show =B3 but I have other cells that use the result in F5 so it can't be a Text format.

How do i do this (preferably not with VB code but I'll take it if that's the only way to do it)

Best Answer

If you have a lot of data you could use this simple VBA method which I believe goes after what you want, or at least points you in the right direction. First of all you can't display the formula and have it calculate without duplicating the cell

If you can get past that part then the next step is to either manually copy each cell and display it as text or use a VBA method like below to do it for you.

I created this sub to show you how to get the formula property of a cell:

Public Sub test()
Range("C1").NumberFormat = "@"
Range("C1").Value = Range("B1").Formula
End Sub

I simply put that formula into a side column as text:

enter image description here

You could of course apply a loop to this to go through an entire sheet.

The other way to achieve what you are looking for is to understand that my argument Range("B1").formula can be set or retrieved. This means that hypothetically you could do it backwards:

dim value as string
value = Range("B1").formula

..then you could use the variable value in additional formulas allowing your formula to be displayed and calculated at the same time.

Hopefully this helps you along your way.