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
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
Hi amivshek,
Maybe?
Or![]()
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
![]()
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...
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks