Move row automatically to the bottom of the sheet when cell changes

Status
Not open for further replies.

CindyLou

New Member
Joined
Jun 23, 2020
Messages
12
Office Version
  1. 365
Platform
  1. Windows
I have a column of "Open" and "Closed" items. When the cell is changed to "Closed," I'm trying to get the whole row to go to the bottom of the spreadsheet. I've tried following a few other threads with no luck. Thanks!
 
My suggestion will be:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  Dim tempArray As Variant
  With Application
  tempArray = Rows(Target.Row)
  .EnableEvents = False
  .ScreenUpdating = False
  Target.EntireRow.Delete
  Cells(Rows.Count, 1).End(xlUp).Offset(1).Resize(, UBound(tempArray, 2)).Value = tempArray
  .ScreenUpdating = True
  .EnableEvents = True
  End With
End Sub
 
Upvote 0

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Do you mean to delete the blank row instead of leaving it there?
You would just need to add a line like:
VBA Code:
Rows(r).Delete
Yes, I tried to reply saying never mind because I realized I got rid of the row delete to see what it would do. Now I am having a problem when the row it moves to the bottom is removed from the table it was in, which messes up some of the lookup code I have inserted in for it
 
Upvote 0
Yes, I tried to reply saying never mind because I realized I got rid of the row delete to see what it would do. Now I am having a problem when the row it moves to the bottom is removed from the table it was in, which messes up some of the lookup code I have inserted in for it
The original question was not dealing with tables. Dealing with tables is different than dealing with lists/rows of data that are not contained in tables.
You should probably ask your question in its own, new thread, since it is a very different situation than the original question that was posed in this thread.
 
Upvote 0
Right-click on the sheet tab name at the bottom of the screen, select "View Code", and paste this code in the resulting VB Editor window that pops up.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    Dim r As Long

    If Target.CountLarge > 1 Then Exit Sub
   
'   See if cell just updated is in column D, if not exit sub
    If Target.Column <> 4 Then Exit Sub
   
'   See if cell just updated set to "Closed"
    If Target.Value = "Closed" Then
        r = Target.Row
'       Move to end
        Application.EnableEvents = False
        Rows(r).Cut
        Cells(Rows.Count, "A").End(xlUp).Offset(1, 0).Select
        ActiveSheet.Paste
        Rows(r).Delete
        Application.EnableEvents = True
    End If

End Sub
This code should run autoamtically when you update a cell in column D to "Closed".

Is there a way to use this code with paste values? I am able to move my rows but it is moving them with formulas in tact. I just want to move the values over
 
Upvote 0
Is there a way to use this code with paste values? I am able to move my rows but it is moving them with formulas in tact. I just want to move the values over
I see that you posted this question to its own thread, which is probably the best thing to do.
But please just be sure to only post the question one time (see rule 12 here for rules on Duplicate Posting: Message Board Rules).
I am locking this thread and leaving your new question open.
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,215,326
Messages
6,124,265
Members
449,149
Latest member
mwdbActuary

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