Change Event

J

Jan Kronsell

I'm using the Worksheet_Change Event to put som information in Column D if
changes happens i Column C.

If I type ie anything in C3, "ABC" is added in D3. I Can later Delete the
"ABC" manually. This works perfectly allrigt. My problem is, that if I
Delete the contents og C3 then I do not want D3 to change. So is thefre a
way I can check if the change is a Clearcontent. I've tried with

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 3 And Target.ClearContents = True Then
Exit Sub
Else
If Target.Column = 3 Then
If Range("D" & Target.Row) = "" Then
Range("D" & Target.Row) = Range("INITIALER").Value
End If
End If
End If
End Sub


But that makes anything types i Columsn C to be deleted.

Jan
 
G

Gary''s Student

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 3 And Target.Value = "" Then
Exit Sub
Else
If Target.Column = 3 Then
If Range("D" & Target.Row) = "" Then
Range("D" & Target.Row) = Range("INITIALER").Value
End If
End If
End If
End Sub
 
D

Don Guillett

try

Private Sub Worksheet_Change(ByVal Target As Range)
Tr = Target.Row
If Len(Application.Trim(Target)) < 1 Or Cells(Tr, "d") <> "" Then Exit Sub
If Target.Column = 3 Then Cells(Tr, "d") = Range("INITIALER")
End Sub
 
J

Jan Kronsell

Of Course! Thank you.

Jan

Gary''s Student said:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 3 And Target.Value = "" Then
Exit Sub
Else
If Target.Column = 3 Then
If Range("D" & Target.Row) = "" Then
Range("D" & Target.Row) = Range("INITIALER").Value
End If
End If
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

Top