+ Reply to Thread
Results 1 to 2 of 2

Find specific values in a column

Hybrid View

amivshek Find specific values in a... 06-09-2011, 12:29 PM
realniceguy5000 Re: Find specific values in a... 06-09-2011, 02:54 PM
  1. #1
    Registered User
    Join Date
    06-09-2011
    Location
    Wyoming, USA
    MS-Off Ver
    Excel 2003
    Posts
    2

    Find specific values in a column

    I am wanting to make a macro or something that will look into a specific column and find the rows that have a specific value in that column and then either delete the other rows or copy these rows into a new worksheet. Thanks

  2. #2
    Valued Forum Contributor realniceguy5000's Avatar
    Join Date
    03-20-2008
    Location
    Fl
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    951

    Re: Find specific values in a column

    Hi amivshek,

    Maybe?


    Option Explicit
    Option Compare Text
    Public Sub KeepRows()
    Dim i As Long
    Dim iLastRow As Long
    Dim col As Range
    Dim sLookfor As String
    With ActiveSheet
    Set col = Application.InputBox("Use mouse to select target column", Type:=8)
    If Not col Is Nothing Then
    sLookfor = InputBox("Look for what string?")
    If sLookfor <> "" Then
    iLastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
    For i = iLastRow To 2 Step -1
    If Not .Cells(i, col.Column).Value Like sLookfor Then
    Rows(i).Delete
    End If
    Next i
    End If
    End If
    End With
    End Sub
    Or

    Option Explicit
    Option Compare Text
    Public Sub MoveRows()
    Dim i As Long
    Dim iLastRow As Long
    Dim col As Range
    Dim sLookfor As String
    With ActiveSheet
    Set col = Application.InputBox("Use mouse to select target column", Type:=8)
    If Not col Is Nothing Then
    sLookfor = InputBox("Look for what string?")
    If sLookfor <> "" Then
    iLastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
    For i = iLastRow To 2 Step -1
    If Not .Cells(i, col.Column).Value Like sLookfor Then
    Else
    Rows(i).Copy
    Sheets(2).Range("A65000").End(xlUp).Offset(1, 0).PasteSpecial (xlValues)
     
    End If
    Next i
    End If
    End If
    End With
    End Sub
    Thank You, Mike

    Some Helpful Hints:

    1. New members please read & follow the Forum Rules
    2. Use Code Tags...Place[code]Before the first line and[/code] After the last line.
    3. If you are pleased with a solution mark your post SOLVED.
    4. Thank those who have help you by clicking the scales at the top right of the post.

    Here...

+ Reply to Thread

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