Delete Row when cell contains another cell text

Kell2Jam

New Member
Joined
May 10, 2020
Messages
33
Office Version
  1. 2013
Platform
  1. Windows
Hi, very new to this.

I need help with finding data from one sheet to finding data in another sheet and deleting that row.
I have had a lot of trouble with this and cant seem to crack it.
Can anyone help a formula?
 

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.
First of all welcome to the board. A few points below...

and deleting that row...
Can anyone help a formula?
You can't delete with a formula, you would need VBA.

A few bits of info that we would need to know to write any VBA...
The names of both sheets
How you are determining the data to Find.
What Ranges/Columns we are looking at.
Basically we need a more detailed description of what you are doing. Describe how you would do the task manually.
 
Upvote 0
ok. so manually i would copy the row i intend to use, go over to another worksheet and paste it over the row with the same data. the purpose of this is to take data collected previously and add it to a newly updated data sheet.

I have attached pictures to give a better indication as to what needs to be done.

Example:Last report tab A2:J2 needs to be pasted over A3:J3 in Open PO's Report as they are the same Purch.Doc
 

Attachments

  • Old Data.JPG
    Old Data.JPG
    212.7 KB · Views: 14
  • New Data.JPG
    New Data.JPG
    198 KB · Views: 15
Upvote 0
If your layout matches what you have posted then try the code below. Make sure that you test it on a copy of your workbook.

VBA Code:
Sub Test1()
    Dim myCell As Range, endCell As Long, destCell As Range
    Application.ScreenUpdating = False
    
    With Sheets("Last report")
        For Each myCell In .Range("A2:A" & .Range("A" & Rows.Count).End(xlUp).Row)
            If myCell.Value <> myCell.Offset(-1).Value Then
                endCell = .Columns("A").Find(myCell.Value, , xlValues, , xlByRows, xlPrevious).Row
                Set destCell = Sheets("Open PO's").Columns("A").Find(myCell.Value, , xlValues, , xlByRows, xlNext)
                Range(.Cells(myCell.Row, "A"), .Cells(endCell, "J")).Copy destCell
            End If
        Next
    End With
    
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Might help if you state what the error says
 
Upvote 0
That means that the sheet name is incorrect. Check the spelling is correct and that you have no leading or trailing spaces. Probably needs changing from "Open PO's" to "Open PO's Report".
 
Upvote 0

Forum statistics

Threads
1,223,748
Messages
6,174,264
Members
452,553
Latest member
red83

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