Macro To Change a Formula to A Value

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a formula in ColB of my worksheet.

The value of the formula will be zero or a positive number.

Is it possible for a macro to change the formula to its value if the value
is not equal to zero ?

Thank you in advance.
 
Sub changetoval()
Range("B2:B8").Select 'ADJUST RANGE!
For Each cella In Selection
If cella <> 0 Then
cella.Value = cella
End If
Next cella
End Sub

Regards,
Stefi


„carl†ezt írta:
 
Stefi,

No need to do wasteful selecting

Sub changetoval()
For Each cella In Range("B2:B8") 'ADJUST RANGE!
If cella <> 0 Then
cella.Value = cella.Value
End If
Next cella
End Sub


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top