Move Rows To a Specific Worksheet Based on Entry in a Cell

StarFL

New Member
Joined
Dec 25, 2018
Messages
6
Hello - I've searched the forum, but not found anything that specifically addresses my issue.

I have a task list workbook that contains 4 sheets: Master, Today, Assigned and Done. All tasks are entered in Master, and I want to have the row deleted from Master and moved to the next available row on one of the other 3 worksheets based on the entry in column F - to Today if I enter a "T", Assigned if I enter "A" or Done if I enter "D".

I'm currently using code provided by My Aswer Is This (Thanks!) in response to another poster to move items from Master, Today and Assigned to Done. Works brilliantly and presumably still will for moving completed items from Today and Assigned to Done - but, I'd like to modify the code on the Master worksheet to move tasks to either T or A or D.

As my experience with VBA doesn't extend much further than copying and pasting code, I am hoping for the kind assistance of one more knowledgeable. The existing code is as follows:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)If Not Intersect(Target, Range("F:F")) Is Nothing Then
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
Dim Lastrow As Long
Lastrow = Sheets("Done").Cells(Rows.Count, "F").End(xlUp).Row + 1


    If Target.Value = "D" Then
        Rows(Target.Row).Copy Destination:=Sheets("Done").Rows(Lastrow)
        Rows(Target.Row).Delete
    End If


End If
Exit Sub

End Sub


Thanks in advance for your help.

Star
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Hi.
This code will copy/paste range A:J ~~~> Resize(, 10) ~~~> change it to suit

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
 Dim ws As Worksheet
  If Target.Count > 1 Then Exit Sub
  If Target.Column <> 6 Then Exit Sub
   For Each ws In ThisWorkbook.Worksheets
    If Left(ws.name, 1) = UCase(Target.Value) Then
     Cells(Target.Row, 1).Resize(, 10).Copy ws.Cells(Rows.Count, 1).End(3)(2)
     Rows(Target.Row).Delete
     Exit Sub
    End If
   Next ws
End Sub
 
Upvote 0
Osvaldo - Thank you for your response! The items on the list are being moved to the proper sheet, but rather than being added on at the next available row, items are moved to the first row of the target sheet, replacing what was already there. Can you add code that moves the item to the next open row on the target sheet instead?

Thanks again - Star
 
Upvote 0
Hi.
Sorry, probably the column A of the target sheets is not the first column that contains data, that's where the code looks for the first empty row.
Please, what is the first column with data on the target sheets?
 
Upvote 0
There is a Title in A1, a blank row, column headings in A3:G3, then the actual data starting at A4.
 
Upvote 0
... column headings in A3:G3, ...

Then, the code is ok. First time the code will paste in A4:J4, the next time it will paste in A5:J5, and so on.

If range with data is A:G, then you could change to Resize(, 7)
 
Upvote 0
Will you always have data in col A?
 
Upvote 0
Try this (looking for the first empty row in column B, instead).

Code:
[COLOR=#652191][I]Cells(Target.Row, 1).Resize(, 7).Copy ws.Range("A" & ws.Cells(Rows.Count, 2).End(3)(2).Row)[/I][/COLOR]
 
Upvote 0

Forum statistics

Threads
1,215,676
Messages
6,126,161
Members
449,295
Latest member
DSBerry

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