I want to delete rows which contains value "WHI", I have highlighted it.
Sub DeleteRowss()
'
' DeleteRowss Macro
'
'
Sheets("Sheet1").Select
ActiveSheet.Range("A1").AutoFilter Field:=1, Criteria1:="*WHI*", Operator:=xlFilterValues
Range("A1").Select
ActiveCell.Offset(1, 0).Rows("1:1").EntireRow.Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Delete Shift:=xlUp
Worksheets("sheet1").AutoFilterMode = False
End Sub
You can try this one
Rich (BB code):Sub DeleteRowss() ' ' DeleteRowss Macro ' ' Sheets("Sheet1").Select ActiveSheet.Range("A1").AutoFilter Field:=1, Criteria1:="*WHI*", Operator:=xlFilterValues Range("A1").Select ActiveCell.Offset(1, 0).Rows("1:1").EntireRow.Select Range(Selection, Selection.End(xlDown)).Select Selection.Delete Shift:=xlUp Worksheets("sheet1").AutoFilterMode = False End Sub
Put your sheet name where it says sheet 1
Thanks for the reply, for some reason it doesnt work
Go to the code in vba and have your excel sheet open, put your cursor inside the vba code some where, press f8 to step through the code 1 line at a time and watch it work. Then let me know where you have the error and what is the error message
if the error is referencing a line then copy and paste that line back here
or you can send me a copy of your data and I can fix the code to work on it.
The code worked for me in the test file you sent, it deleted all the rows where the A cell contained WHI
I just found out a mistake of mine. All of the cells Containing "WHI" has an ending "..WHI-S", "...WHI-M", "...WHI-L" etc. Exept one type of cells containig "WHI" has no additional ending. And I need to keep those cells. Here is another smaple I attached. The red color cells with "WHI" should remain, and yellow color should be deleted. Is it possible do that?
https://rokastestas.s3.eu-west-3.amazonaws.com/sample2.xlsm
Please explain why Rows 18, 34 and 50 (just to name a small few) should be deleted when they contain just WHI at the end.