PDA

View Full Version : Solved: Trigger event on change/deactive/leave of a specific cell



andrewvanmar
11-09-2007, 03:08 AM
I want to check the value in cell B, when cell A is changed or left, to see if the value is numeric, and copy the value to cell C if the value is numeric.

for now I have this



IF isnumeric (Sheet1.B1) Then
(sheet2.C2).Value = (sheet1.B1).Value
Else
(Sheet2.C2).Value = " "
End if



What i need is the event that triggers this something like:


OnDeactivate (sheet1.A1)
but I have no idea how to make sure that it triggers

andrewvanmar
11-09-2007, 03:29 AM
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Range("n29"), Target) Is Nothing Then
If IsNumeric(Range("p29").Value) Then
Sheets("Signatures and pricing").[G5].Value = Range("p29").Value
Else
Sheets("Signatures and pricing").[G5].Value = ""
End If
End If
End Sub

n29 is cell A
P29 is cell B
G5 is cell C

Bob Phillips
11-09-2007, 05:17 AM
You should use Target, more flexible



Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Me.Range("n29"), Target) Is Nothing Then
If IsNumeric(Target.Offset(0,2).Value) Then
Sheets("Signatures and pricing").Range("G5").Value = Target.Offset(0,2).Value
Else
Sheets("Signatures and pricing").Rang("G5").Value = ""
End If
End If
End Sub

andrewvanmar
11-09-2007, 05:20 AM
but doesn't that refer to cell A then? I want the cell checked to be a different one from the one that triggers the event.

Target.Offset(0,2) what does this exactly mean ( the offset?)

Bob Phillips
11-09-2007, 05:22 AM
I don't see any reference to A in your code.

And I realise that the value picked up is dfferent to the trigger cell, I used Offset for that.