Clear Contents

hallingh

Well-known Member
Joined
Sep 11, 2010
Messages
769
How do you use vba to clear the contents of the cell without erasing the formula?

In other words, I want the cell to show "" but still contain the original formula. Right now I just have:

Code:
ActiveSheet.Range("Q15").ClearContents

This erases the formula from the cell as well.

Thanks!

Hank
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
You would have to look at copy and pastespecial and paste Formula

Sample

Range("A4").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteFormulas
 
Upvote 0
Hey,

You will have to change your formula. What are you using at the moment?
 
Upvote 0
Trevor that worked great, thanks!

Is there any way to do the same thing but with a list? as in a list from data validation?
 
Upvote 0
Need a little more information, can you upload a sample of the sheet via Excel Jeanie and then specify your requirements.
 
Upvote 0
Yeaaaa can't really download anything unfortunately i'm on a work computer :confused:

All im trying to do is clear the contents of a cell that has a drop down list but keep the drop down list there..

If you cant help without code no biggie I'll keep playin around with it and see if i can figure it out
 
Upvote 0
If the list comes from another location and you want to clear a range of cells then you could use

Range("A1:A12").ClearContents

If one of the cells has a formula in then do as previously suggested.
 
Upvote 0
I'm baffled. You can't clear the contents of a cell and keep its formula, since the formula is the contents.
 
Upvote 0

Forum statistics

Threads
1,215,110
Messages
6,123,146
Members
449,098
Latest member
Doanvanhieu

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