+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    08-27-2009
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    1

    Question Macro help deleting rows with selected character strings

    Hello.

    I am new to Excel macro programming in visual basic, and have a macro that I would like to use to make my work a bit easier.

    I need to create a macro to search out the following strings of characters in a column:

    "MIL-STD"
    "J-STD"
    "WS"
    "0D"
    "DWG"

    When it finds any of these strings in the column, it would delete the associated row.

    Any help on this would be greatly appreciated.

    Thank you in advance!
    Last edited by rliccion; 08-27-2009 at 11:41 AM. Reason: title fix

  2. #2
    Forum Moderator shg's Avatar
    Join Date
    06-21-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2007
    Posts
    25,138

    Re: Macro Programming Help

    Welcome to the forum.

    Please take a few minutes to read the forum rules, and then amend your thread title accordingly.

    Thanks.
    Microsoft MVP - Excel
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    06-05-2009
    Location
    Charlotte
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: Macro help deleting rows with selected character strings

    Code:
    Dim cell_check As Variant
    Dim range_check As Range
    Dim nCol As Long
    Dim rCount As Long
    
    With ActiveSheet
        nCol = Application.Match("Row anem goes here", .Rows(1), 0)
        For rCount = .UsedRange.Rows.Count To 2 Step -1
            Select Case .Cells(rCount, nCol).Value
            Case = "MIL-STD", "J-STD", "WS", "0D", "DWG"
                    .Rows(rCount).EntireRow.Delete
            End Select
        Next
    End With
    Last edited by jseufert; 08-28-2009 at 06:43 PM.

  4. #4
    Forum Moderator shg's Avatar
    Join Date
    06-21-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2007
    Posts
    25,138

    Re: Macro help deleting rows with selected character strings

    jseufert, please edit your post to add code tags.
    Microsoft MVP - Excel
    Entia non sunt multiplicanda sine necessitate

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.2.0