ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Check for wrong cell content (https://www.excelbanter.com/excel-programming/410411-check-wrong-cell-content.html)

Oldjay

Check for wrong cell content
 
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.

Norman Jones[_2_]

Check for wrong cell content
 
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
'<<==========



---
Regards.
Norman


"Oldjay" wrote in message
...
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.




All times are GMT +1. The time now is 04:36 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com