I fixed the spreadsheet.
https://www.dropbox.com/s/uhkq6trv88ftc9t/Monthly Report VBA ESIS.xlsx?dl=0
Thanks,
Michael
Hi
Try the code below
Hope it works for you
MarkCode:Sub DeleteRowWithContents() '======================================================================== ' DELETES ALL ROWS FROM A2 DOWNWARDS WITH THE WORDs "Record Only" IN COLUMN D '======================================================================== Last = Cells(Rows.Count, "D").End(xlUp).Row For i = Last To 1 Step -1 If (Cells(i, "D").Value) = "Record Only" Then 'Cells(i, "A").EntireRow.ClearContents ' USE THIS TO CLEAR CONTENTS BUT NOT DELETE ROW Cells(i, "A").EntireRow.Delete End If Next i End Sub
Why loop ?
Try AutoFilter ...
Code:Sub test() With ActiveSheet .AutoFilterMode = False With Range("d1", Range("d" & Rows.Count).End(xlUp)) .AutoFilter 1, "*Record Only*" On Error Resume Next .Offset(1).SpecialCells(12).EntireRow.Delete End With .AutoFilterMode = False End With End Sub
SiuGuy007,
Thanks for the workbook/worksheet.
Here is a new macro for you to consider based on the new raw data structure.
Sample raw data:
...
Code:Sub SiuGuy007_ESIS_Plus() ' hiker95, 03/07/2016, ME300330 Columns("I").Replace "ESIS", "#N/A", xlWhole Columns("I").Replace "ESIS*", "#N/A", xlWhole On Error Resume Next Columns("I").SpecialCells(xlConstants, xlErrors).EntireRow.Delete On Error GoTo 0 End Sub
Is it possible to do the same thing on the rows containing a specific string? I mean: this macro works only if the value of the cell is exactly "ESIS". What about if would like to remove the cells like "TExt 1 ESIS", "Text Text ESIS Text"?
francopiva,
Welcome to the MrExcel forum.
So that I can get it right on the first try:
We would like more information. Please see the Forum Use Guidelines in the following link:
http://www.mrexcel.com/forum/board-announcements/127080-guidelines-forum-use.html
See reply #2 at the next link, if you want to show small screenshots, of the raw data, and, what the results should look like.
http://www.mrexcel.com/forum/about-board/508133-attachments.html#post2507729
Or, you can post your workbook/worksheets to the following free site (sensitive data changed), mark the workbook for sharing, and, provide us with a link to your workbook:
https://dropbox.com
Excel 2007 | |||
---|---|---|---|
I | |||
1 | Title I | ||
2 | ESIS | ||
3 | not this | ||
4 | not this | ||
5 | TExt 1 ESIS | ||
6 | not this | ||
7 | not this | ||
8 | not this | ||
9 | Text Text ESIS Text | ||
10 | not this | ||
11 | |||
Sheet1 |
Excel 2007 | |||
---|---|---|---|
I | |||
1 | Title I | ||
2 | not this | ||
3 | not this | ||
4 | not this | ||
5 | not this | ||
6 | not this | ||
7 | not this | ||
8 | |||
9 | |||
10 | |||
11 | |||
Sheet1 |
Sub francopiva_ESIS_Plus()
' hiker95, 11/30/2016, ME300330
Columns("I").Replace "ESIS", "#N/A", xlWhole
Columns("I").Replace "ESIS*", "#N/A", xlWhole
Columns("I").Replace "*ESIS*", "#N/A", xlWhole
On Error Resume Next
Columns("I").SpecialCells(xlConstants, xlErrors).EntireRow.Delete
On Error GoTo 0
End Sub