R
ryguy7272
I wanted to filter several columns for values that match a certain criteria.
Then I thought a copy/paste routine would work better (there are too many
columns to use the filter tool). I found this simple cut/paste code on this
DG a while back and I tried to use it today and it didn’t do anything. Can
someone please tell me why?
Sub a()
Dim Cell As Range
Dim CutRg As Range
For Each Cell In Sheet1.Range("AR1:BJ2000")
If Cell.Value = "sam" Then
If CutRg Is Nothing Then
Set CutRg = Cell.EntireRow
Else
Set CutRg = Union(CutRg, Cell.EntireRow)
End If
End If
Next
If Not CutRg Is Nothing Then
CutRg.Copy Sheet2.Range("A1")
CutRg.Delete
End If
End Sub
There may be multiple instances of the value sought in multiple
columns/rows. I am hoping to copy the entire row if even one instance of the
value is found.
Thanks,
Ryan---
Then I thought a copy/paste routine would work better (there are too many
columns to use the filter tool). I found this simple cut/paste code on this
DG a while back and I tried to use it today and it didn’t do anything. Can
someone please tell me why?
Sub a()
Dim Cell As Range
Dim CutRg As Range
For Each Cell In Sheet1.Range("AR1:BJ2000")
If Cell.Value = "sam" Then
If CutRg Is Nothing Then
Set CutRg = Cell.EntireRow
Else
Set CutRg = Union(CutRg, Cell.EntireRow)
End If
End If
Next
If Not CutRg Is Nothing Then
CutRg.Copy Sheet2.Range("A1")
CutRg.Delete
End If
End Sub
There may be multiple instances of the value sought in multiple
columns/rows. I am hoping to copy the entire row if even one instance of the
value is found.
Thanks,
Ryan---