Hello guys,
I've been doing some research on this topic, I found some VBA code but I am unable to make it work on my main sheet, any kind soul out there who could help me out? All I want is for the row that is marked as "invoiced/completed" on the drop down of column C to be automatically sent to the last row, ideally this would happen as "selection change" instead of manually having to run the macro.
This the code I was looking at... I modified it somewhat, but it would not work.
I've been doing some research on this topic, I found some VBA code but I am unable to make it work on my main sheet, any kind soul out there who could help me out? All I want is for the row that is marked as "invoiced/completed" on the drop down of column C to be automatically sent to the last row, ideally this would happen as "selection change" instead of manually having to run the macro.
This the code I was looking at... I modified it somewhat, but it would not work.
VBA Code:
Sub MoveToEnd()
Dim xRg As Range
Dim xTxt As String
Dim xCell As Range
Dim xEndRow As Long
Dim I As Long
On Error Resume Next
If ActiveWindow.RangeSelection.Count > 1 Then
xTxt = ActiveWindow.RangeSelection.AddressLocal
Else
xTxt = ActiveSheet.UsedRange.AddressLocal
End If
lOne:
Set xRg = Application.Range("C:C")
If xRg Is Nothing Then Exit Sub
If xRg.Columns.Count > 1 Or xRg.Areas.Count > 1 Then
MsgBox " Multiple ranges or columns have been selected ", vbInformation, "Kutools for Excel"
GoTo lOne
End If
xEndRow = xRg.Rows.Count + xRg.Row
Application.ScreenUpdating = False
For I = xRg.Rows.Count To 1 Step -1
If xRg.Cells(I) = "Invoiced/Completed" Then
xRg.Cells(I).EntireRow.Cut
Rows(xEndRow).Insert Shift:=xlDown
End If
Next
Application.ScreenUpdating = True
End Sub