Note that it is "AAA1000" and not "AAAF1000"
Lars-ke
On Wed, 11 Nov 2009 15:53:01 -0800, John_John
<(E-Mail Removed)> wrote:
>Another diferent approach:
>
>Sub DeleteRows()
> Dim i As Integer
> Dim rngFound As Range
> Dim rngAllRows As Range
>
> On Error Resume Next
> Set rngAllRows = Range("A:A")
> For i = 800 To 1000 Step 100
> Set rngFound = Range("A:A").Find("AAAF" & i)
> If Not rngFound Is Nothing Then
> Set rngAllRows = rngAllRows.ColumnDifferences(rngFound)
> End If
> Set rngFound = Nothing
> Next i
> rngAllRows.EntireRow.Delete
>End Sub
>
>? ??????? "Lars-ke Aspelin" ???????:
>
>> On Wed, 11 Nov 2009 11:44:01 -0800, SITCFanTN
>> <(E-Mail Removed)> wrote:
>>
>> >I need to write some code that would delete all rows in the open document
>> >where AAAF800 or AAAF900 or AAA1000 are not in column A. I have searched the
>> >site and am not able to find anything that would help me with this. Any
>> >suggestions are greatly appreciated. Thank you,
>>
>>
>> Try this macro:
>>
>> Sub delete_rows()
>> For r = Cells.SpecialCells(xlCellTypeLastCell).Row To 1 Step -1
>> If Not (Cells(r, "A") = "AAAF800" Or _
>> Cells(r, "A") = "AAAF900" Or _
>> Cells(r, "A") = "AAA1000") Then
>> Rows(r).Delete
>> End If
>> Next r
>> End Sub
>>
>> Hope this helps / Lars-ke
>> .
>>
|