ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Find "Not Equal" (https://www.excelbanter.com/excel-programming/369486-find-not-equal.html)

Rick

Find "Not Equal"
 
I have this code (thank you very much, really) but I need to modify it a bit.
I only want to copy and paste the first four columns AND I only want the
lines that DO NOT have the word "Hold" in column a:

Sub MoveNotHold()
Dim rngToSearch As Range
Dim rngFound As Range
Dim rngFoundAll As Range
Dim rngPaste As Range
Dim strFirstAddress As String

Set rngPaste = Sheets("Roll").Cells(Rows.Count, _
"A").End(xlUp).Offset(1, 0)
Set rngToSearch = Sheets("Alpha").Range("A1:E99")
Set rngFound = rngToSearch.Find(What:="Hold", _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
MatchCase:=False)
If rngFound Is Nothing Then
MsgBox "There are no items to move."
Else
Set rngFoundAll = rngFound
strFirstAddress = rngFound.Address
Do
Set rngFoundAll = Union(rngFound, rngFoundAll)
Set rngFound = rngToSearch.FindNext(rngFound)
Loop Until rngFound.Address = strFirstAddress

rngFoundAll.EntireRow.Copy Destination:=rngPaste
'rngFoundAll.EntireRow.Delete 'Optional to Delete
End If
End Sub



All times are GMT +1. The time now is 01:26 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com