Help with the code........URGENT PLEASE

fari1

Active Member
Joined
May 29, 2011
Messages
362
Code:
Sub newcode() 
    startrow = 2 
    Sheets("statement").Select 
    lastrow = Cells(Rows.Count, "A").End(xlUp).Row 
    Sheets("sheet1").Select 
    sheet1rows = Cells(Rows.Count, "A").End(xlUp).Row 
    For Y = 1 To sheet1rows 
        Sheets("sheet1").Select 
        searchvalue = Cells(Y, "A").Value 
        Sheets("statement").Select 
        For X = lastrow To startrow Step -1 
            If Cells(X, "A").Value = searchvalue Then Cells(X, "A").EntireRow.Delete 
        Next 
    Next 
End Sub

it finds and delete based upon whatever is in column A of sheet1.
it works perfect except for one little problem.
e.g its deletes all the rows, where there's just apple in a single cell, it wont consider those rows where there's apple in the long text strings. say in row A5 i've text string, i like apple, then it wont delete that row, while i want it to delete that as well
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Perhaps

Code:
If LCase(Cells(X, "A").Value) Like "*" & LCase(searchvalue) & "*" Then Cells(X, "A").EntireRow.Delete

Assuming you want to treat Apples the same as apples (case wise)
 
Upvote 0
Please do not post the same question multiple times. All clarifications, follow-ups, and bumps should be posted back to the original thread. Per forum rules, posts of a duplicate nature will be locked or deleted (rule #9 here: http://www.mrexcel.com/forum/showthread.php?t=99490).
 
Upvote 0

Forum statistics

Threads
1,224,551
Messages
6,179,480
Members
452,915
Latest member
hannnahheileen

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