VBA help - automatically move row to the bottom of a table once a specific value is entered.

emztruong

New Member
Joined
Oct 12, 2020
Messages
2
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Hello!

Can someone please kindly assist with the following?

Once cell F is marked with a "y", I'd like that specific row to move to the bottom of the table. Ideally I want to keep a record of all previous data so the table would need to keep expanding but not sure if that's a possibility.

Thanks in advance :)
Emily

Screenshot.jpg
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Welcome to MrExcel

Place code in SHEET code window
- NOT in a module, NOT in ThisWorkbook code window

Right click on sheet tab , select View Code , paste code into that window
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim tbl As ListObject, wRow As Long
    Set tbl = Me.ListObjects(1)
    If Target.CountLarge > 1 Then Exit Sub
        If Not Intersect(Target, tbl.ListColumns("Paid Y/N").Range) Is Nothing Then
            If UCase(Target.Value) = "Y" Then
            Application.ScreenUpdating = False
            wRow = Target.Row - tbl.HeaderRowRange.Row
            tbl.ListRows.Add AlwaysInsert:=True
            tbl.DataBodyRange.Rows(wRow).Copy tbl.DataBodyRange.Rows(tbl.ListRows.Count)
            tbl.ListRows(wRow).Delete
        End If
    End If
End Sub
 
Upvote 0
Hi Yongle,

That didn't seem to work. Also, it needs to be "Y" for column F "Collected".

Thanks
Emily
 
Upvote 0
The code works for me - so we should be able to make it work for you
Please post the amended code that you used and In will test it
 
Upvote 0

Forum statistics

Threads
1,215,553
Messages
6,125,483
Members
449,233
Latest member
Deardevil

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top