Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to clear contents of a cell but keep formulas? 1

Status
Not open for further replies.

coolcarls

Technical User
Jan 19, 2002
182
US
I am using vb to clear the text from a range of cells but I really need to keep the formulas intact, I've tried to .range.clearcontents and range.text="" but errors keep on coming. Any clue??
Thanks a lot
Carl
 
Hi Carl,

Range("xxxx").ClearContents will work - where you replace "xxxx" with whatever range name you assign to the range you want cleared.

From your description, it appears you might have a situation where the range includes "input" cells "inter-mixed" with other cells containing formulas.

If you're attempting to clear all the "input" cells in one step, this IS possible, but you will need to create a range name for a "disjointed" range.

This is done by:

1) Hold down the <Control> key.

2) Use the mouse to click on all the individual disjointed cells that you want included in this one range.

3) With the <Control> key STILL held, hit <F3>

4) Type the name

5) Hit <Enter>

I hope this helps resolve your situation. If your situation is &quot;different&quot;, and you want to email me a copy, I'd be pleased to resolve it and email the file back.

Regards, ...Dale Watson dwatson@bsi.gov.mb.ca
 
Hi - you can't clear the contents AND keep the formula. If you want formulae to show nothing when certain conditions are true (ie no data) you will need to use an IF statement in the formula eg =IF(Test=FALSE,&quot;&quot;,ANSWER)
HTH
~Geoff~
[noevil]
 
Hi Carl
I'm assuming this is the same as your other post, in which case I replied there. My solution is basically the same as Dale's but acts dyamically (I think, I've had a bang on the head) through code. I'd love to know if it works in a real life situation!

me, beer, 2 flights of stairs!
[hammer] If a man says something and there are no women there to hear him, is he still wrong?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top