deleting formulas and pasting values

miconian

Well-known Member
Joined
Aug 18, 2004
Messages
769
Hi,

On page 114 of "Mr. Excel On Excel," this macro is put forth as the way to instantly convert cells containing formulas to cells containing the results of those formulas:
Code:
Selection.Formulas = Selection.Value

This doesn't work with the most common situation I would like to use it in: the sum of two cells. That is, if the formula is =SUM(B1+B2), running the macro returns "Run-time error '438': Object doesn't support this property or method."

What's up with that?

Thanks...
 
what's your entire procedure? What's the selection?
 
Code:
Sub FormulaToValue()
'
' FormulaToValue Macro
' Erases a formula and writes the value of that formula to the same cell.
'
' Keyboard Shortcut: Ctrl+j
'
Selection.Formulas = Selection.Value
End Sub

I don't know what you mean by "What's the selection" beyond what I provided.

I just now tried it with the selection being cell A1, which contains:
Code:
=SUM(B1,B2)

and with cells B1 and B2 both containing the number 45, causing cell A1 to display 90.
 
so it sounds like it worked this time? That line requires you to have the cell with the formula selected. What were you doing earlier?
 
No, it did not work this time.

I meant that cell A1 displays 90 because of the formula. But running that macro while having cell A1 selected does not remove the formula and paste the value. It gives the error mentioned earlier.
 
oh! there's a TYPO.. it should be FORMULA (singular) not formulas (with an S)
 
Thanks. I'll let you know where to mail my share of the royalty checks. ; )
 
sure, I'll give you a share of what I get..
nada :-)
I didn't write this one!
 

Forum statistics

Threads
1,226,834
Messages
6,193,221
Members
453,780
Latest member
enghoss77

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top