ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   clear the values, but not the formulas in a range (https://www.excelbanter.com/excel-programming/342229-clear-values-but-not-formulas-range.html)

aidy

clear the values, but not the formulas in a range
 
I'm trying to clear the values, but not the formulas in this range?

Range("E3:F3, E5:F5").ClearContents

Is it possible?

Cheers

Aidy


Ron de Bruin

clear the values, but not the formulas in a range
 
Hi

You can use

On Error Resume Next
Range("E3:F3, E5:F5").SpecialCells(xlCellTypeConstants).ClearCon tents
On Error GoTo 0


--
Regards Ron de Bruin
http://www.rondebruin.nl


"aidy" wrote in message ups.com...
I'm trying to clear the values, but not the formulas in this range?

Range("E3:F3, E5:F5").ClearContents

Is it possible?

Cheers

Aidy




K Dales[_2_]

clear the values, but not the formulas in a range
 
If a formula evaluates to a value, you can't clear the value without
eliminating the formula. You can hide the value by making the font color
match the background, if that is what you want to do. Or just hide the cells.
--
- K Dales


"aidy" wrote:

I'm trying to clear the values, but not the formulas in this range?

Range("E3:F3, E5:F5").ClearContents

Is it possible?

Cheers

Aidy



K Dales[_2_]

clear the values, but not the formulas in a range
 
Just realized you probably have a mix (unknown to you) of cells with formulas
and values. Try Range("E3:F3,
E5:F5").SpecialCells(xlCellTypeConstants).ClearCon tents.
--
- K Dales


"aidy" wrote:

I'm trying to clear the values, but not the formulas in this range?

Range("E3:F3, E5:F5").ClearContents

Is it possible?

Cheers

Aidy




All times are GMT +1. The time now is 07:00 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com