Thread: Clear formulae
View Single Post
  #13   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson[_3_] Dave Peterson[_3_] is offline
external usenet poster
 
Posts: 2,824
Default Clear formulae

If my formulas were non-contiguous, then that gave me bad results (xl2002).

But I could loop through each contiguous area in the range and it worked ok:

Option Explicit
Sub testme01()

Dim myArea As Range
Dim myRng As Range

Set myRng = Nothing
On Error Resume Next
Set myRng = ActiveSheet.UsedRange.SpecialCells(xlCellTypeFormu las)
On Error GoTo 0

If myRng Is Nothing Then
'no formula cells
Else
For Each myArea In myRng.Areas
With myArea
.Value = .Value
End With
Next myArea
End If
End Sub



Mike wrote:
<<snipped

Trevor,

I didn't have any trouble with the Copy - Paste Special method either
(97 & 2000). I don't think you even need to use a loop in this
situation. Something like:

With ActiveSheet.UsedRange.SpecialCells(xlCellTypeFormu las)
.Value=.Value
End With

should also work.

-Mike


--

Dave Peterson