Move Entire Row To The Bottom Of Active Table Based On non blank Cell

Jd2023

New Member
Joined
Jun 28, 2023
Messages
18
Office Version
  1. 365
Platform
  1. Web
Hi all,

I would like to automatically move an entire row to the bottom of the table when column 'AD' is populated with a date? I have this code which is not working?

Private Sub Worksheet_Change(ByVal Target As Range)

Dim lr As Long
Dim r As Long

' Exit if more than one cell updated at a time
If Target.CountLarge > 1 Then Exit Sub

' Exit it cell updated not on column AD
If Target.Column <> 30 Then Exit Sub

' See if date entered in column
If IsDate(Target) And Target > 0 Then
Application.EnableEvents = False
' Find last row with data in column D
lr = Cells(Rows.Count, "D").End(xlUp).Row
' Move row to bottom of sheet
r = Target.Row
Rows(r).Cut
Cells(lr + 1, "A").Select
ActiveSheet.Paste
Application.CutCopyMode = False
' Delete old row
Rows(r).Delete
Application.EnableEvents = True
End If

End Sub

In addition, I would also like to automatically group rows together when a name is populated in column A?

I would appreciate any help with this.

Kind Regards
Jasmine
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim lr As Long, r As Long
Application.EnableEvents = False
    If Target.Count > 1 Then Exit Sub
    If Intersect(Target, Range("F:F")) Is Nothing Then Exit Sub
    ' See if date entered in column
    If IsDate(Target) Then
        ' Find last row with data in column D
        lr = ActiveSheet.Cells(Rows.Count, "D").End(xlUp).Row
        ' Move row to bottom of sheet
        r = Target.Row
        ActiveSheet.Rows(r).Copy ActiveSheet.Rows(lr + 1)
        ActiveSheet.Rows(r).Delete
'        Application.CutCopyMode = False
    End If
Application.EnableEvents = True
End Sub
 
Upvote 0
Oh, my bad.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim lr As Long, r As Long
Application.EnableEvents = False
    If Target.Count > 1 Then Exit Sub
    If Intersect(Target, Range("AD:AD")) Is Nothing Then Exit Sub
    ' See if date entered in column
    If IsDate(Target) Then
        ' Find last row with data in column D
        lr = ActiveSheet.Cells(Rows.Count, "D").End(xlUp).Row
        ' Move row to bottom of sheet
        r = Target.Row
        ActiveSheet.Rows(r).Copy ActiveSheet.Rows(lr + 1)
        ActiveSheet.Rows(r).Delete
'        Application.CutCopyMode = False
    End If
Application.EnableEvents = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,252
Members
452,623
Latest member
Techenthusiast

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