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

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
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,223,888
Messages
6,175,207
Members
452,618
Latest member
Tam84

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