Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Jan 2004
    Posts
    110
    Thanks
    0
    Thanked 0 Times in 0 Posts

    macro (Excel 2000)

    Hi Gurus,

    I am attaching a worksheet. Am looking for help in writing a macro which will check the numbers in col A and delete the row having numbers starting with Y or X.

    Cheers
    Novicexcelite
    Attached Files Attached Files

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: macro (Excel 2000)

    Here is such a macro:

    Sub DeleteSomeRows()
    Dim r As Long
    Dim m As Long
    ' Last used row
    m = Range("A" & Rows.Count).End(xlUp).Row
    ' Loop backwards
    For r = m To 2 Step -1
    ' Check first character
    Select Case UCase(Left(Range("A" & r), 1))
    Case "X", "Y"
    ' Delete row
    Range("A" & r).EntireRow.Delete
    End Select
    Next r
    End Sub

  3. #3
    2 Star Lounger
    Join Date
    Jan 2004
    Posts
    110
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: macro (Excel 2000)

    Hi Hans,

    Thanks for the quick response which has fulfilled my requirment.

    cheers
    Novice

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: macro (Excel 2000)

    It would also be possible to do this without using a macro:
    - Select cell A1.
    - Select Data | Filter | AutoFilter.
    - Click the dropdown arrow in cell A1.
    - Select Custom...
    - Specify "begins with" in the first dropdown and enter X in the box next to it.
    - Click Or.
    - Select "begins with" in the second dropdown and enter Y in the box next to it.
    - Click OK.
    - Select all filtered (visible rows).
    - Select Edit | Delete.
    - Select Data | Filter | Show All.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •