Hi,
I have the following code working fine for one worksheet change trigger, however it does not run the second worksheet change.
Can anyone help please? Rng one works great, but Rng1 does not run.
Also, I would like to copy the data to the target and then clear the original row, rather than cut.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Rng As Range
Dim Rng1 As Range
Set Rng = Target.Parent.Range("Table2")
Set Rng1 = Target.Parent.Range("Table6")
If Target.Count > 1 Then Exit Sub
If Intersect(Target, Rng) Is Nothing Then Exit Sub
If Target.Value = "8. Booked" Then
Target.EntireRow.Cut _
Range("Table5").End(xlDown).Offset(1, 0)
ActiveWorkbook.Worksheets("Sheet1").ListObjects("Table2").Sort.SortFields.Add _
Key:=Range("Table2[CLV]"), SortOn:=xlSortOnValues, Order:=xlDescending, _
DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Sheet1").ListObjects("Table2").Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Else
If Target.Value = "9. Lost" Then
Target.EntireRow.Cut _
Range("Table1").End(xlDown).Offset(1, 0)
ActiveWorkbook.Worksheets("Sheet1").ListObjects("Table2").Sort.SortFields.Add _
Key:=Range("Table2[CLV]"), SortOn:=xlSortOnValues, Order:=xlDescending, _
DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Sheet1").ListObjects("Table2").Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End If
End If
If Target.Count > 1 Then Exit Sub
If Intersect(Target, Rng1) Is Nothing Then Exit Sub
If Target.Value = "8. Booked" Then
Target.EntireRow.Cut _
Range("Table5").End(xlDown).Offset(1, 0)
Else
If Target.Value = "9. Lost" Then
Target.EntireRow.Cut _
Range("Table1").End(xlDown).Offset(1, 0)
End If
End If
End Sub
Any help would be much appreciated.
Thanks in advance. (sorry for missed tags, pressed save too quickly!)
I have the following code working fine for one worksheet change trigger, however it does not run the second worksheet change.
Can anyone help please? Rng one works great, but Rng1 does not run.
Also, I would like to copy the data to the target and then clear the original row, rather than cut.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Rng As Range
Dim Rng1 As Range
Set Rng = Target.Parent.Range("Table2")
Set Rng1 = Target.Parent.Range("Table6")
If Target.Count > 1 Then Exit Sub
If Intersect(Target, Rng) Is Nothing Then Exit Sub
If Target.Value = "8. Booked" Then
Target.EntireRow.Cut _
Range("Table5").End(xlDown).Offset(1, 0)
ActiveWorkbook.Worksheets("Sheet1").ListObjects("Table2").Sort.SortFields.Add _
Key:=Range("Table2[CLV]"), SortOn:=xlSortOnValues, Order:=xlDescending, _
DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Sheet1").ListObjects("Table2").Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Else
If Target.Value = "9. Lost" Then
Target.EntireRow.Cut _
Range("Table1").End(xlDown).Offset(1, 0)
ActiveWorkbook.Worksheets("Sheet1").ListObjects("Table2").Sort.SortFields.Add _
Key:=Range("Table2[CLV]"), SortOn:=xlSortOnValues, Order:=xlDescending, _
DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Sheet1").ListObjects("Table2").Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End If
End If
If Target.Count > 1 Then Exit Sub
If Intersect(Target, Rng1) Is Nothing Then Exit Sub
If Target.Value = "8. Booked" Then
Target.EntireRow.Cut _
Range("Table5").End(xlDown).Offset(1, 0)
Else
If Target.Value = "9. Lost" Then
Target.EntireRow.Cut _
Range("Table1").End(xlDown).Offset(1, 0)
End If
End If
End Sub
Any help would be much appreciated.
Thanks in advance. (sorry for missed tags, pressed save too quickly!)
Last edited: