J
Janelle S
Thanks to Jim Thomlinson for the following code to move rows to another
worksheet.
This works perfectly where the value in column AV is text however what I
would like is for this column to be a formulae. This formulae is calculated
on whether the case is closed and on date (giving "current"/"non current"
result). The code doesn't seem to recognise the results if there is formulae
in column AV. Please help.
Sub MoveStuff()
Dim rngToSearch As Range
Dim rngFound As Range
Dim rngFoundAll As Range
Dim rngPaste As Range
Dim strFirstAddress As String
Set rngPaste = Sheets("_Non Current").Cells(Rows.Count, _
"A").End(xlUp).Offset(1, 0)
Set rngToSearch = ActiveSheet.Columns("AV")
Set rngFound = rngToSearch.Find(What:="closed", _
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
End If
End Sub
worksheet.
This works perfectly where the value in column AV is text however what I
would like is for this column to be a formulae. This formulae is calculated
on whether the case is closed and on date (giving "current"/"non current"
result). The code doesn't seem to recognise the results if there is formulae
in column AV. Please help.
Sub MoveStuff()
Dim rngToSearch As Range
Dim rngFound As Range
Dim rngFoundAll As Range
Dim rngPaste As Range
Dim strFirstAddress As String
Set rngPaste = Sheets("_Non Current").Cells(Rows.Count, _
"A").End(xlUp).Offset(1, 0)
Set rngToSearch = ActiveSheet.Columns("AV")
Set rngFound = rngToSearch.Find(What:="closed", _
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
End If
End Sub