HELPP!! Simple MACRO help!

Solved/Closed
lsn11 - Jul 25, 2016 at 04:27 PM
vcoolio Posts 1411 Registration date Thursday July 24, 2014 Status Moderator Last seen September 6, 2024 - Jul 26, 2016 at 08:18 PM
Hello,

I would like to create a macro that will scan sheet one for cells that contain the word "Complete", Copy the whole row, and paste it into another sheet (Sheet 2 - "Complete") without overwriting the rows in sheet 2. And Finally Deleting the copied "Completed" rows from sheet one.

I am having trouble finding a select row by certain text feature to start the macro with.

PLEASE HELP!

Text Word "Completed"
Sheet one name - "All PO'S"
Sheet two name - "Completed"
Related:

3 responses

Blocked Profile
Jul 25, 2016 at 04:30 PM
Post some code with the steps you are stuck with. We can help you with broken code! We cannot provide a FREE turn key solution for your business! We are volunteers, and help when you need help!

Record a macro and post it here, start with that!
0
Hi! I completely understand. This is a macro formula I found in a similar forum I messed around with but does not work.

Sub Macro1()
Dim LR As Long
Range("A2").EntireRow.Insert Shift:=xlDown
LR = Sheets("ALL PO'S").Cells(Rows.Count, "C").End(xlUp).Row
LR1 = Sheets("Completed").Cells(Rows.Count, "A").End(xlUp).Row + 1
With Sheets("Data").Range("C2:C" & LR)
.AutoFilter
.AutoFilter Field:=1, Criteria1:="ERROR", _
Operator:=xlOr, Criteria2:="MISSING"
.SpecialCells(xlCellTypeVisible).EntireRow.Copy Destination:=Sheets("Errors").Range("A" & LR1)
.SpecialCells(xlCellTypeVisible).EntireRow.Delete
End With
End Sub
0
vcoolio Posts 1411 Registration date Thursday July 24, 2014 Status Moderator Last seen September 6, 2024 262
Jul 26, 2016 at 12:27 AM
Hello Isn11,

The code you have doesn't quite deal with the description you gave in your opening post.

1) You do not appear to be wanting to insert rows. This would not be relevant in your case.

2) The criteria you stated as "Complete" (or is it "Completed"?). The code above has two criteria: "ERROR" and "MISSING" which appear to be irrelevant to your case.

Hence, I would say that the following amended code may be more relevant to your query:-

Sub MoveIt()

  Dim lr As Long

Application.ScreenUpdating = False

With ActiveSheet
    .AutoFilterMode = False
With Range("C1", Range("C" & Rows.Count).End(xlUp))
        .AutoFilter 1, "Completed"
        lr = ActiveSheet.Range("C" & Rows.Count).End(xlUp).Row
        If lr > 1 Then
        .Offset(1).EntireRow.Copy Sheets("Completed").Range("A" & Rows.Count).End(xlUp).Offset(1)
        .Offset(1).EntireRow.Delete
        End If
    End With
    .AutoFilterMode = False
End With

Application.CutCopyMode = False
Application.ScreenUpdating = True
Sheets("Completed").Select

End Sub


The "ActiveSheet" is your main or input sheet ("ALL PO'S") from where the code will be run.

I've assumed that the criteria is in Column C as per the code that you supplied.

See how it works out for you and let us know your thoughts.

Cheerio,
vcoolio.
0
vcoolio Posts 1411 Registration date Thursday July 24, 2014 Status Moderator Last seen September 6, 2024 262
Jul 26, 2016 at 08:18 PM
Hello Isn11,

Sadly, you have cross-posted and not advised anyone that you have done so.

We consider that between this forum and the other in which you have posted, you have enough information to resolve your query by yourself.

Please familiarise yourself with the rules of any forum before signing up.

Hence, this thread will be closed and marked as solved.

Cheerio,
vcoolio.
0