Setting Cells Equal only if Destination Cell Does Not Have a Formu

  • Thread starter Thread starter adambush4242
  • Start date Start date
A

adambush4242

Is there a way in VBA to set a cell equal to another cell only if the
destination cell does not contain a formula (has a value)?

Thanks

Adam Bush
 
Yes. Here we check A2 to make sure it has not formula:

Sub save_formula()
Set a1 = Range("A1")
Set a2 = Range("A2")
If a2.HasFormula Then
Else
a2.Value = a1.Value
End If
End Sub
 
Gary,

Thanks you very much. I did not know that hasformula was a property.

Thanks

Adam Bush
 

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