Last active
January 22, 2016 13:00
-
-
Save danwagnerco/7105f1123dd164f43c7f to your computer and use it in GitHub Desktop.
This script deletes rows that match "Invoice.zip" or "Thumbs.db"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Option Explicit | |
Public Sub DeleteRowsWithForLoop() | |
Dim wksData As Worksheet | |
Dim lngLastRow As Long, lngIdx As Long | |
'Set references up-front | |
Set wksData = ThisWorkbook.Worksheets("data") | |
With wksData | |
'Identify the last row | |
lngLastRow = .Range("F" & .Rows.Count).End(xlUp).Row | |
'Loop from the BOTTOM to the top, deleting rows as you go | |
For lngIdx = lngLastRow To 6 Step -1 | |
If .Cells(lngIdx, 6) = "Invoice.zip" Or _ | |
.Cells(lngIdx, 6) = "Thumbs.db" Then | |
.Rows(lngIdx).Delete | |
End If | |
Next lngIdx | |
End With | |
'Let the user know the script has finished | |
MsgBox "Boom! Rows deleted." | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment