Deleting Cell Contents Leave Code

ryderlane

New Member
Joined
Nov 2, 2018
Messages
7
Hello All!

I'm using this code to delete contents in a Cell

Private Sub CommandButton2_Click()

Sheets("Calculator").Range("K3").Value = "$0"

End Sub

How do I keep the Formula in Excel from deleting every time I hit the "Clear Button"?

Thank you!
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
You can't.
What exactly are you trying to do?
 
Upvote 0
I have X2 Cells that populate once a certain drop down is selected. I wanted to add a button to just delete the contents in one cell, while leaving the formula. Does this make sense?
 
Upvote 0
The only way to remove a value from a cell with a formula that gets the value from precedent cells, is to delete the values of the precedent cells. Any value coerced into the cell with the formula will overwrite the formula, and that includes and empty string value ("").
 
Last edited:
Upvote 0
Change the formula to reflect the need for a zero value, so you don't have to clear it each time.
 
Upvote 0
Perhaps a picture will help,,,,,,,,,,I'm trying to delete the contents in the "VFP Pricing Field" with a button without clearing the formula. Just for that field.

An image I am afraid doesn't alter the fact that you can't clear a cell and keep the formula.

Perhaps if you posted the formula and provide a description of in what circumstances you want the cell to appear blank then someone help amend the formula as per Michael's suggestion.
 
Upvote 0
Dosn't help at all...we know what you want to do.
What is the formula currently in the VFD cell ??
 
Last edited:
Upvote 0
=IF(G3="5m³",'NutriJet 10 1.5 HP VFD '!E9,IF(G3="10m³",'NutriJet 10 3HP VFD'!E9,IF(G3="1.5HP","$0","$0")))
 
Upvote 0
So you could either

Code:
=IF(G3="5m³",'NutriJet 10 1.5 HP VFD '!E9,IF(G3="10m³",'NutriJet 10 3HP VFD'!E9,IF(G3="1.5HP","$0","")))....[color=red] Is blank if nothing is true[/color]
OR

Code:
=IF(G3="5m³",'NutriJet 10 1.5 HP VFD '!E9,IF(G3="10m³",'NutriJet 10 3HP VFD'!E9,IF(G3="1.5HP","","")))....[color=red] Is blank if G3 or nothing is true[/color]

OR

Code:
=IF(G3="5m³",'NutriJet 10 1.5 HP VFD '!E9,IF(G3="10m³",'NutriJet 10 3HP VFD'!E9,IF(G3="1.5HP","","$0")))....[color=red] Is blank if G3 is true[/color]

A button shouldn't be required at all
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,162
Members
453,021
Latest member
Justyna P

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