Macro to delete rows
I'm getting a syntax error here Mike:
If c.Interior.Color = RGB(204, 255, 204) Or UCase(c.Value) = "DISTRICT"
Thanks,
Jeff
"Mike H" wrote:
Jeff,
Based upon your latest description, my modified macro. Note I've used the
RGB numbers you provided but it looks suspiciously green to me.
Sub delete_Me2()
Dim CopyRange As Range
Set sht = Sheets("Sheet1")
sht.Rows("1:13").Delete
lastrow = sht.Cells(Cells.Rows.Count, "A").End(xlUp).Row
Set MyRange = sht.Range("A1:A" & lastrow)
For Each c In MyRange
If c.Interior.Color = RGB(204, 255, 204) Or UCase(c.Value) = "DISTRICT"
Then
If CopyRange Is Nothing Then
Set CopyRange = c.EntireRow
Else
Set CopyRange = Union(CopyRange, c.EntireRow)
End If
End If
Next
If Not CopyRange Is Nothing Then
CopyRange.Delete
End If
End Sub
--
Mike
When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.
"JeffF" wrote:
To clarify:
1) Delete rows 1-13
2) Delete all rows where the word "District" appears in column A
3) Find all rows AFTER row 1 that are highlighted in blue and delete them
(these are separators that would mess up my sorting and I don't need them.
They come in with these cells filled with the color R 204, G 255, B 204).
For #3, I can't say "delete any row that has a specific word" to delete the
header because the header is actually 3 different rows, only one of which
would have the specific word.
Thanks again.
"JeffF" wrote:
I'd appreciate some help in creating a macro to delete rows.
Here's what I need:
1) Delete rows 1-13
2) Then find all rows that are highlited blue and delete them
3) Then find all rows that include the text "Distr" and delete them
Suggestions?
Thanks in advance.
|