grichey
06-26-2008, 11:20 AM
Code Below. I'm trying to delete any row that doesn't have a background of none or white as well as any empty rows. The problem is the way I've looped it deletes a row and jumps to the next to check but by deleting they all move up so if there's two non white or empty rows back to back it skips one.
:banghead:
Option Explicit
Sub RPT1()
Dim counter1 As Integer
Dim stopper1 As Integer
counter1 = 6 'leaves header on report
stopper1 = InputBox("enter stopper", "enter stopper") 'for last row of report
' The above needs to be better
Do
'Below deletes rows with color in background
If Rows(counter1).Interior.ColorIndex = x1None _
Or Rows(counter1).Interior.ColorIndex = 2 _
Or (Application.CountA(Range("A" & counter1).EntireRow) = 0) _
Then
Rows(counter1).EntireRow.Delete
counter1 = counter1 + 1 'loops to next row
Loop Until counter1 = stopper1 'stops when you've reached last row entered at inputbox
MsgBox ("Finished") 'Finish
End Sub
:banghead:
Option Explicit
Sub RPT1()
Dim counter1 As Integer
Dim stopper1 As Integer
counter1 = 6 'leaves header on report
stopper1 = InputBox("enter stopper", "enter stopper") 'for last row of report
' The above needs to be better
Do
'Below deletes rows with color in background
If Rows(counter1).Interior.ColorIndex = x1None _
Or Rows(counter1).Interior.ColorIndex = 2 _
Or (Application.CountA(Range("A" & counter1).EntireRow) = 0) _
Then
Rows(counter1).EntireRow.Delete
counter1 = counter1 + 1 'loops to next row
Loop Until counter1 = stopper1 'stops when you've reached last row entered at inputbox
MsgBox ("Finished") 'Finish
End Sub