Question : Excel Macro to Delete Rows Based on Conditions

I am importing some html documents into Excel and would like to clean up the presentation before saving it as an Excel file.  I would like to create a macro to remove a bunch of blank rows as well as some rows that start like this:

Z:\websitepublic\......
No Selected Documents Found in this Directory

The text above is always in Column D and E.

I also need to remove duplicate rows that have the following column headings:

Documents Title Author Subject Keywords Created Saved date_created date_reviewed creator version

I'm new to creating macros in Excel and would appreciate some advice on how to do this.

Answer : Excel Macro to Delete Rows Based on Conditions

Use this code...

Saurabh...

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
Sub deleterows()
Application.ScreenUpdating = False

    Dim srow As Long
    srow = 1

    Do Until srow > Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
        If InStr(1, Cells(srow, "a"), "Z:\websitepublic\", vbTextCompare) > 0 Or InStr(1, Cells(srow, "a"), "No selected documents in this directory", vbTextCompare) > 0 Then
            Rows(srow).Delete


        ElseIf Application.WorksheetFunction.CountA(Range(srow & ":" & srow)) = 0 Then
         Rows(srow).Delete
         Else
            srow = srow + 1
        End If
    Loop


Application.ScreenUpdating = True
End Sub
Random Solutions  
 
programming4us programming4us