whitoulias
Board Regular
- Joined
- Jun 22, 2012
- Messages
- 153
Hi,
Excel version: 2016
I am trying unsuccessfully to combine two handlers.
The first one finds the value "Yes" in Column H and moves it to the Settled sheet. There is an issue though with this one as it seems that the data are copied to the Settled sheet over and over in row A instead of one under the other
The second tracks the changes users make
Has anyone have any idea how can I combine both in one?
Thank you in advance
Excel version: 2016
I am trying unsuccessfully to combine two handlers.
The first one finds the value "Yes" in Column H and moves it to the Settled sheet. There is an issue though with this one as it seems that the data are copied to the Settled sheet over and over in row A instead of one under the other
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Lastrow = Worksheets("Active").UsedRange.Rows.Count
lastrow2 = Worksheets("Settled").UsedRange.Rows.Count
If lastrow2 = 1 Then
lastrow2 = 0
Else
End If
Do While Application.WorksheetFunction.CountIf(Range("H:H"), "Yes") > 0
Set Check = Range("H1:H" & Lastrow)
For Each Cell In Check
If Cell = "Yes" Then
Cell.EntireRow.Copy Destination:=Worksheets("Settled").Range("A" & lastrow2 + 1)
Cell.EntireRow.Delete
lastrow2 = lastrow2 + 1
Else:
End If
Next
Loop
End Sub
The second tracks the changes users make
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Not Intersect(Target, Range("L:L")) Is Nothing Then
If Target.Count > 1 Then Exit Sub
Cells(Target.Row, "K").Value = Environ("username") & " " & Format(Now, "dd/mm/yyyy hh:mm:ss")
End If
If Not Intersect(Target, Range("I:I")) Is Nothing Then
If Target.Count > 1 Then Exit Sub
Cells(Target.Row, "J").Value = Environ("username") & " " & Format(Now, "dd/mm/yyyy")
End If
Application.EnableEvents = True
End Sub
Has anyone have any idea how can I combine both in one?
Thank you in advance