Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Option Explicit
- Private Sub Worksheet_Change(ByVal Target As Range)
- Application.EnableEvents = False
- If Target.Cells.Count > 1 Then
- GoTo done
- If Application.Intersect(Target, ActiveSheet.Range("G:G")) Is Nothing Then
- GoTo done
- If Target.Value <> "Hold" And Target.Value <> "Yes" And Target.Value <> "No" And Target.Value <> "Eat" Then
- GoTo done
- MoveRowInTable Target.Value
- Dim i As Long
- For i = 1 To Target.Count
- If Target(i).Value > 0 Then
- MoveRowsInTableTarget(i).Value
- End If
- Next
- done: Application.EnableEvents = True
- End Sub
- Module1
- ------
- Sub MoveRowsInTable()
- Dim sourceTable As ListObject
- Dim destinationTable As ListObject
- Dim selectedRow As ListRow
- Dim lastRow As ListRow
- Dim Cell As Variant
- Set sourceTable = Worksheets("Unpaid").ListObjects("Table1")
- Set selectedRow = sourceTable.ListRows(Selection.Row - sourceTable.HeaderRowRange.Row)
- If Cell = "Yes" Then
- Set destinationTable = Worksheets("Paid").ListObjects("Table2")
- ElseIf Cell = "No" Then
- Set destinationTable = Worksheets("Collect").ListObjects("Table3")
- ElseIf Cell = "Eat" Then
- Set destinationTable = Worksheets("Credit").ListObjects("Table4")
- End If
- lastRow = destinationTable.ListRows.Add
- lastRow.Range.Value = selectedRow.Range.Value
- selectedRow.Delete
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement