Results 1 to 12 of 12

Delete columns based on cell criteria

Threaded View

  1. #1
    Forum Contributor
    Join Date
    12-03-2009
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    184

    Delete columns based on cell criteria

    Hello All,

    I'm using the attached code (thanks to someone on this site) to delete a column based on whether a set characters exist in row 2. This currently looks for the letters "FP1". How would I make this work to look for FP1, FP2, FP3, FP4. I don't want to look for all of them, just one, so if any of them exist, delete the column.

    tx

    E.

    Sub Clear_Cleanup()
    
    Dim delFIND As Range
    
    On Error Resume Next
    
    With ActiveSheet
        Set delFIND = .Rows(2).Find("FP1", LookIn:=xlValues, LookAt:=xlWhole)
    
        If Not delFIND Is Nothing Then
            Do
                .Columns(delFIND.Column).Delete xlShiftToLeft
                Set delFIND = .Rows(2).Find("FP1", LookIn:=xlValues, LookAt:=xlWhole)
            Loop Until delFIND Is Nothing
        End If
    End With
    
    End Sub
    Last edited by enhydra; 04-19-2011 at 09:05 PM.

Thread Information

Users Browsing this Thread

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

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.6.0 RC 1