Check to see if a formula is correct

  • Thread starter Thread starter oldjay
  • Start date Start date
O

oldjay

I want to do something like this
Sub Macro1()

If Range("A1") =(=B1 + B2) Then ' This is a formula
Exit Sub
Else
Range("C1").Select 'Has correct formula
Selection.Copy
Range("A1").Select
Selection.PasteSpecial Paste:=xlFormulas
End If

End Sub
How do I do this?
 
Hi

Try
Sub Macro1()

If Range("A1").HasFormula Then
Exit Sub
Else
Range("C1").Copy
Range("A1").PasteSpecial Paste:=xlFormulas
Application.CutCopyMode = False
End If

End Sub

Regards
Roger Govier
 
Try

If Range("A1").Formula <> "=B1+B2" Then
Range("A1").Formula = Range("C1").Formula
End If
 
Back
Top