That's rather inefficient. Try:
Dim ws As Worksheet
Dim rConvert As Range
Dim rMask As Range
For Each ws In Worksheets(Array(...))
With ws
Set rMask = Union(.Rows(5).Resize(.Rows.Count - 4), _
.Columns(4).Resize(4, .Columns.Count - 3))
Set rConvert = Intersect(.UsedRange, rMask)
If Not rConvert Is Nothing Then _
rConvert.Value = rConvert.Value
End With
Next ws
which converts formulas to values in all the cells in the worksheet
(except those masked) in one step, rather than looping through each cell.
In article <(E-Mail Removed)>,
Ray <(E-Mail Removed)> wrote:
> I tried to implement your suggestion, but the code errored out on the
> Intersect line .... here is the error and the code as I'm using it:
>
> RunTime 1004: Method 'Intersect' of Object '_Global' failed
>
>
> Sub ValueOutDSRs()
> Dim sh As Worksheet
>
> Application.Calculation = xlCalculationManual
> For Each sh In Sheets(Array("DSR - 152",<a bunch of sheets here>,"DSR
> - 250", "DSR - 921"))
>
> sh.Activate
> Set rp = Range("A4:C4")
> For Each r In ActiveSheet.UsedRange
> If Intersect(r, rp) Is Nothing Then
> r.Formula = r.Value
> End If
> Next r
>
> Next sh
> Application.Calculation = xlCalculationxlAutomatic
>
> End Sub
>
> Any thoughts?
|