I have enclosed some code for a macro, I now have a need to have several sTxts to work with instead of one.
I tried a couple of variations,
example - sTxt = "Saturday" Or "Friday", sTxt = "Friday" or "Saturday"
But when I attempt to run, I am getting a mismatch error msg.
Any suggestions, or help in how I could accomplish this, would be appreciated.
.............................................................
Sub FindEm2()
Dim tempcell As Range, Found As Range, sTxt
sTxt = "Saturday"
With Range("E1:E600")
For Each cell In Range("E1:E600")
Set tempcell = .Cells.Find(What:=sTxt)
If tempcell Is Nothing Then
MsgBox prompt:="Not found"
Exit Sub
Else
tempcell.Offset(0, 0).Resize(1).Cut Destination:=tempcell.Offset(2, -2)
Set Found = tempcell
End If
Do
On Error Resume Next
Set tempcell = .Cells.FindNext(After:=Found)
On Error GoTo 0
If Found.Row >= tempcell.Row And Found.Column >= tempcell.Column Then Exit Do
tempcell.Offset(0, 0).Resize(1).Cut Destination:=tempcell.Offset(2, -2)
Set Found = tempcell
Loop
Next cell
End With
Application.CutCopyMode = False
End Sub
I tried a couple of variations,
example - sTxt = "Saturday" Or "Friday", sTxt = "Friday" or "Saturday"
But when I attempt to run, I am getting a mismatch error msg.
Any suggestions, or help in how I could accomplish this, would be appreciated.
.............................................................
Sub FindEm2()
Dim tempcell As Range, Found As Range, sTxt
sTxt = "Saturday"
With Range("E1:E600")
For Each cell In Range("E1:E600")
Set tempcell = .Cells.Find(What:=sTxt)
If tempcell Is Nothing Then
MsgBox prompt:="Not found"
Exit Sub
Else
tempcell.Offset(0, 0).Resize(1).Cut Destination:=tempcell.Offset(2, -2)
Set Found = tempcell
End If
Do
On Error Resume Next
Set tempcell = .Cells.FindNext(After:=Found)
On Error GoTo 0
If Found.Row >= tempcell.Row And Found.Column >= tempcell.Column Then Exit Do
tempcell.Offset(0, 0).Resize(1).Cut Destination:=tempcell.Offset(2, -2)
Set Found = tempcell
Loop
Next cell
End With
Application.CutCopyMode = False
End Sub