I'm writing a macro that searches for text in a file and then copies the cell and the cell next to it to another sheet.
I've gotten to the point where it does exactly what I state above but the problem is the search keeps on looping and adding the same values (I added a max of 25 times to the loop for test.
How do I stop the script when it's found all matches?
Sub Macro7()
'
' Macro7 Macro
'
'
Sheets("Input").Select
Range("A9").Select
Sheets("KKS").Select
Range("A1").Select
On Error GoTo subend
Let x = 0
Do While x = 0
Sheets("KKS").Select
Cells.Find(What:="MY0-0HTT25AP", After:=ActiveCell, LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
Selection.Resize(numRows + 1, numColumns + 2).Select
Selection.Copy
Sheets("Input").Select
ActiveSheet.Paste
ActiveCell.Offset(1, 0).Select
x = x + 1
Loop
subend:
End Sub
If anyone knows how to do this I would be very happy if they could help me out
Bookmarks