Skip to content

Instantly share code, notes, and snippets.

Last active January 22, 2016 13:00
What would you like to do?
This script deletes rows that match "" or "Thumbs.db"
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) = "" Or _
.Cells(lngIdx, 6) = "Thumbs.db" Then
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