PDA

View Full Version : Change formulas to values, but with some exceptions



MrTinkertrai
08-20-2010, 12:37 AM
Hello Excel-gurus,

The other day I was looking for a piece of code that would change formulas into their values.
I found the following piece of code that does the trick :


Sub F2V()
Dim rng As Range

On Error Resume Next

For Each rng In ActiveSheet.Cells.SpecialCells(xlCellTypeFormulas).Areas
rng.Value = rng.Value
Next rng

On Error GoTo 0
End Sub
The only range where I would like to change my formulas into values is the range B8:K55.

How can I change this code so that it fit my needs ?

Thanx in advance

Best regards,

Mike

Artik
08-20-2010, 01:21 AM
eg.Sub F2V_1()
Dim rng As Range

On Error Resume Next

For Each rng In Range("B8:K55").SpecialCells(xlCellTypeFormulas).Areas
rng.Value = rng.Value
Next rng

On Error GoTo 0
End Sub

But it will be faster:Sub F2V_2()

On Error Resume Next

With Range("B8:K55")
.Value = .Value
End With

On Error GoTo 0
End Sub

Artik

MrTinkertrai
08-20-2010, 02:22 AM
Thanx for your reply, Artik
Works like a charm :thumb