Check for wrong cell content

  • Thread starter Thread starter Oldjay
  • Start date Start date
O

Oldjay

I wish to check a cell to be sure it has a formula in it. If the cell has a
zero or number in it then I want to copy a cell with the correct formula in
to it.
 
Hi OldJay,

Try something like:

'==========>>
Public Sub Tester()
Dim WB As Workbook
Dim SH As Worksheet
Dim Rng As Range
Dim Rng2 As Range

Set WB = Workbooks("myBook.xls") '<<==== CHANGE
Set SH = WB.Sheets("Sheet2") '<<==== CHANGE

With SH
Set Rng = .Range("A1") '<<==== CHANGE
Set Rng2 = .Range("C1") '<<==== CHANGE
End With

If Not Rng.HasFormula Then
Rng2.Copy Destination:=Rng
End If

End Sub
'<<==========
 

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