View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default Delete rows containing Vendor Total A,B,C etc

I think your may need to run this loop backwards to make it work step -1

"Pranav Vaidya" wrote:

try the below code

Worksheets("Sheet2").Activate
Dim i As Integer
Dim LastRow As Long
LastRow = Range("A65000").End(xlUp).Row
For i = 2 To LastRow
If InStr(1, Range("A" & i).Value, "Vendor Total") Then Rows(i).Delete
Next

"iansmigger" wrote:

Hi

I am looking for a macro that will delete entire rows from a report
containing the phrase 'Vendor Total' followed by Company name.

Here is an example of the raw data:-

Company Apple
Vendor Total Company Apple
Vendor Total Company Banana
Vendor Total Company Banana
Company Orange
Company Apple
Vendor Total Comapany Pear

Once the macro has run and deleted out the entire lines containg Vendor
Total, the following data should remain:-

Company Apple
Company Orange
Company Apple

There is a header in row 1 that should remain.

Thanks