ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Change Event (https://www.excelbanter.com/excel-programming/403702-change-event.html)

Jan Kronsell

Change Event
 
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




Gary''s Student

Change Event
 
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

--
Gary''s Student - gsnu2007c


"Jan Kronsell" wrote:

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





Don Guillett

Change Event
 
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
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

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





Jan Kronsell

Change Event
 
Of Course! Thank you.

Jan

Gary''s Student wrote:
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


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





All times are GMT +1. The time now is 09:48 PM.

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