How can I create a Macro that will move a row from one sheet to another based on its cell value

jlsrexcel

New Member
Joined
Mar 6, 2020
Messages
4
Office Version
  1. 365
Platform
  1. MacOS
So I currently need to help someone with this issue, the spreadsheet is below:

To Do List is row 1. I want to move all the rows which says 'YES' in the complete column, for example, F6 says YES, so I want to move row 6 from the sheet 'Open Tasks' to a new sheet called 'Completed Tasks'. Please could you help me create a Macro for this?

To Do List
Today's Date Friday, 6 March 2020
Day Priority Task Notes Task TypeCompleteCompletion Date
ThursMedium RaveCall NoTuesday
WedLow RepeatMeetingNoFriday
FriHigh TennisSportYESMonday
ThursMedium RaveCall NoTuesday
WedLow RepeatMeetingYESFriday
FriHigh TennisSportNoMonday
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Assuming that the Yes/No appears in column F starting at row 2.
Code:
Sub t()
Dim c As Range
    With Sheets("Open Tasks")
        For i = .Cells(Rows.Count, "F").End(xlUp).Row To 2 Step -1
            If LCase(.Cells(i, 6).Value) = "yes" Then
                .Rows(i).Copy Sheets("Completed Tasks").Cells(Rows.Count, 1).End(xlUp)(2)
                .Rows(i).Delete
            End If
        Next
    End With
End Sub
 
Upvote 0
Here is a screenshot of my file below. What would I do in this case?
 

Attachments

  • Screenshot 2020-03-09 at 09.46.41 (2)-min.png
    Screenshot 2020-03-09 at 09.46.41 (2)-min.png
    78.1 KB · Views: 24
Upvote 0
I copied and pasted the Macro, but it returns the error "Compile Error: Can't find project or Library"
 
Upvote 0
I copied and pasted the Macro, but it returns the error "Compile Error: Can't find project or Library"
When the error appears, open the vb editor, Alt + F11, then click 'Tools' on the menu bar then click 'References'. Find the missing Libraty reference and click the check box. That should make the error go away. Click on link for full description by MS.


If you have not used VBA before, you might need to make sure all of your security settings have been adjusted. To do that , in Excel click File >Options>Trust Center>Trust Center Settings>Macros and select the options that allow you to use VBA.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,872
Messages
6,122,025
Members
449,060
Latest member
LinusJE

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