Moving rows to different sheets

Cstewart29

New Member
Joined
Feb 8, 2023
Messages
4
Office Version
  1. 365
Platform
  1. Windows
Hi,

So I have been trying to build a spreadsheet that requires moving rows of information from the main "Caseload" sheet into any one of 12 sheets (January-December) in the same document, also deleting the information from the "caseload" sheet.
The idea would be to highlight the row and click a button that will move the row. I have decided to add to column R a drop down list 1-12 to use to determine which month to transfer to.

Now while I have created a button to move a row to ONE other sheet before, this task has proven too much so far so I was hoping to ask some smart person for help?

Thanks to anyone who can help. Let me know if there is anything I haven't made clear!
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Hello! Did you ever figure this out? Could you share if so?

Thank you!
 
Upvote 0
Try the following on a copy of your data. Assumptions (in the absence of any data sample provided) include that the dropdown list consists of the months "January, February, March..."etc.; and that each sheet (other than the Caseload sheet) is named exactly as the various month names in the validation list; that you want the row data from column A-Q inclusive moved (not column R); and that each month sheet has a header row in row 1. If any of these assumptions are wrong, please advise otherwise.

VBA Code:
Option Explicit
Sub Move_Row()
    On Error GoTo Escape
    Application.EnableEvents = False
    
    Dim ws As String, rng As Range
    ws = Intersect(ActiveCell.EntireRow, Columns(18)).Value2
    
    If Selection.Cells.CountLarge > 1 Then
        MsgBox "Select one row only"
        Exit Sub
    End If
    
    If ws = "" Then
        MsgBox "No Month Selected in column R"
        Exit Sub
    End If
    
    If MsgBox("You're about to move Row" & ActiveCell.Row & " to sheet " & ws & vbNewLine _
    & "Do you wish to proceed?", vbYesNo, "Confirm") = vbNo Then
        Exit Sub
    End If
    
    Set rng = Intersect(ActiveCell.EntireRow, Range("A:Q"))
    With rng
        .Copy Worksheets(ws).Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
        .EntireRow.Delete
    End With
    
Continue:
    Application.EnableEvents = True
    Exit Sub
Escape:
    MsgBox "Error " & Err.Number & ": " & Err.Description
    Resume Continue
End Sub
 
Upvote 0
Solution
Try the following on a copy of your data. Assumptions (in the absence of any data sample provided) include that the dropdown list consists of the months "January, February, March..."etc.; and that each sheet (other than the Caseload sheet) is named exactly as the various month names in the validation list; that you want the row data from column A-Q inclusive moved (not column R); and that each month sheet has a header row in row 1. If any of these assumptions are wrong, please advise otherwise.

VBA Code:
Option Explicit
Sub Move_Row()
    On Error GoTo Escape
    Application.EnableEvents = False
   
    Dim ws As String, rng As Range
    ws = Intersect(ActiveCell.EntireRow, Columns(18)).Value2
   
    If Selection.Cells.CountLarge > 1 Then
        MsgBox "Select one row only"
        Exit Sub
    End If
   
    If ws = "" Then
        MsgBox "No Month Selected in column R"
        Exit Sub
    End If
   
    If MsgBox("You're about to move Row" & ActiveCell.Row & " to sheet " & ws & vbNewLine _
    & "Do you wish to proceed?", vbYesNo, "Confirm") = vbNo Then
        Exit Sub
    End If
   
    Set rng = Intersect(ActiveCell.EntireRow, Range("A:Q"))
    With rng
        .Copy Worksheets(ws).Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
        .EntireRow.Delete
    End With
   
Continue:
    Application.EnableEvents = True
    Exit Sub
Escape:
    MsgBox "Error " & Err.Number & ": " & Err.Description
    Resume Continue
End Sub
Hi,

This worked very well. Thanks so much its great! Makes the sheet work so much better.
 
Upvote 0
Try the following on a copy of your data. Assumptions (in the absence of any data sample provided) include that the dropdown list consists of the months "January, February, March..."etc.; and that each sheet (other than the Caseload sheet) is named exactly as the various month names in the validation list; that you want the row data from column A-Q inclusive moved (not column R); and that each month sheet has a header row in row 1. If any of these assumptions are wrong, please advise otherwise.

VBA Code:
Option Explicit
Sub Move_Row()
    On Error GoTo Escape
    Application.EnableEvents = False
   
    Dim ws As String, rng As Range
    ws = Intersect(ActiveCell.EntireRow, Columns(18)).Value2
   
    If Selection.Cells.CountLarge > 1 Then
        MsgBox "Select one row only"
        Exit Sub
    End If
   
    If ws = "" Then
        MsgBox "No Month Selected in column R"
        Exit Sub
    End If
   
    If MsgBox("You're about to move Row" & ActiveCell.Row & " to sheet " & ws & vbNewLine _
    & "Do you wish to proceed?", vbYesNo, "Confirm") = vbNo Then
        Exit Sub
    End If
   
    Set rng = Intersect(ActiveCell.EntireRow, Range("A:Q"))
    With rng
        .Copy Worksheets(ws).Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
        .EntireRow.Delete
    End With
   
Continue:
    Application.EnableEvents = True
    Exit Sub
Escape:
    MsgBox "Error " & Err.Number & ": " & Err.Description
    Resume Continue
End Sub
Thank you!
 
Upvote 0

Forum statistics

Threads
1,215,734
Messages
6,126,542
Members
449,316
Latest member
sravya

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