C
Cloudfall
A contributor to this newsgroup kindly created the following example
code for me, which worked with the "MsgBox cell.Address" statement,
that is, it found each instance of "A" in the spreadsheet and displayed
its address. But I can't change the code to get it to cut and paste
rows to another worksheet. This is the original code:
Sub findit()
Dim cell As Range
Dim sFirst As String
Set cell = Cells.Find("A")
If Not cell Is Nothing Then
MsgBox cell.Address
sFirst = cell.Address
Do
Set cell = Cells.FindNext(cell)
If Not cell Is Nothing And cell.Address <> sFirst Then
MsgBox cell.Address
End If
Loop Until cell Is Nothing Or sFirst = cell.Address
End If
End Sub
My implementation requires that I cut and paste each of the "found"
rows from this worksheet into another. Each time I have tried to
implement this, either I get an error at the end after it has cut and
pasted all instances of the "found" rows, or something else goes wrong.
The above code seems to work without "selecting" any cells. As soon as
I select a cell or even use "cell.cut", which seems to select the cell
in order to cut it, the code begins misbehaving.
I can't seem to work out how to simply find something in my worksheet,
cut the row it's in, paste the row to another worksheet, come back to
the original worksheet, repeat the find/ cut/ paste/ return/, and then
elegantly exit when no further instances remain.
Thanking you now for any help.
code for me, which worked with the "MsgBox cell.Address" statement,
that is, it found each instance of "A" in the spreadsheet and displayed
its address. But I can't change the code to get it to cut and paste
rows to another worksheet. This is the original code:
Sub findit()
Dim cell As Range
Dim sFirst As String
Set cell = Cells.Find("A")
If Not cell Is Nothing Then
MsgBox cell.Address
sFirst = cell.Address
Do
Set cell = Cells.FindNext(cell)
If Not cell Is Nothing And cell.Address <> sFirst Then
MsgBox cell.Address
End If
Loop Until cell Is Nothing Or sFirst = cell.Address
End If
End Sub
My implementation requires that I cut and paste each of the "found"
rows from this worksheet into another. Each time I have tried to
implement this, either I get an error at the end after it has cut and
pasted all instances of the "found" rows, or something else goes wrong.
The above code seems to work without "selecting" any cells. As soon as
I select a cell or even use "cell.cut", which seems to select the cell
in order to cut it, the code begins misbehaving.
I can't seem to work out how to simply find something in my worksheet,
cut the row it's in, paste the row to another worksheet, come back to
the original worksheet, repeat the find/ cut/ paste/ return/, and then
elegantly exit when no further instances remain.
Thanking you now for any help.