Thread: IF in vba
View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Newbeetle Newbeetle is offline
external usenet poster
 
Posts: 98
Default IF in vba

Thankyou

"JE McGimpsey" wrote:

Change the line in the second event macro from

If Target.Address = "C28" Then

to

If Target.Address(False, False) = "C28" Then


In article ,
Newbeetle wrote:

I copied the code into a completly new workbook and placed it in Excel
objects sheet one, I then went to the Excel sheet and typed note in Cell C28,
but the cell D28 stays blank.

Any futher ideas appreciated.

"Tom Ogilvy" wrote:

You would need to run a macro which is written in VBA.

Right click on the sheet tab and select view code.

Put in code like this:

Private Sub Worksheet_Calculate()
If InStr(1, Range("C28"), "note", vbTextCompare) Then
Range("D28") = CVErr(xlErrNA)
Else
If Range("D28") = CVErr(xlErrNA) Then
Range("D28").ClearContents
End If
End If
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "C28" Then
If InStr(1, Range("C28"), "note", vbTextCompare) Then
Range("D28") = CVErr(xlErrNA)
Else
If Range("D28") = CVErr(xlErrNA) Then
Range("D28").ClearContents
End If
End If
End If
End Sub