Sub Transfer123()
Dim fCell As Range
Dim firstAdd As String
Dim pasteRow As Long
Dim pasteCol As String
Dim wsDest As Worksheet
Dim wsSource As Worksheet
'Which column to go to?
pasteCol = "A"
'Where are we going to?
Set wsDest = Worksheets("Results")
'Where are we coming from?
Set wsSource = Worksheets("Sheet1")
Application.ScreenUpdating = False
'Search for the 123 value
With wsSource.Range("A:A")
Set fCell = .Find(what:=123, lookat:=xlWhole, LookIn:=xlValues)
If fCell Is Nothing Then
MsgBox "No values found"
Exit Sub
End If
firstAdd = fCell.Address
Do
pasteRow = wsDest.Cells(.Rows.Count, pasteCol).End(xlUp).Offset(1).Row
If pasteRow > 2 Then pasteRow = pasteRow + 1
fCell.CurrentRegion.Copy wsDest.Cells(pasteRow, pasteCol)
Set fCell = .FindNext(fCell)
Loop Until fCell.Address = firstAdd
End With
Application.ScreenUpdating = True
End Sub
Sub Demo()
Dim Rg As Range
With Sheet1.Range("A1", Sheet1.Cells(Rows.Count, 1).End(xlUp))
Set Rg = .Find(123, .Cells(.Count), xlValues, xlWhole)
If Rg Is Nothing Then Beep: Exit Sub
Application.ScreenUpdating = False
AD$ = Rg.Address
Sheet2.UsedRange.Clear
Do
Rg.CurrentRegion.Copy Sheet2.Cells(Rows.Count, 1).End(xlUp)(3 + (Rg.Address = AD))
Set Rg = .FindNext(Rg)
Loop Until Rg.Address = AD
Set Rg = Nothing
End With
Application.Goto Sheet2.Cells(1), True
End Sub
Sub Transfer123()
Dim fCell As Range
Dim firstAdd As String
Dim pasteRow As Long
Dim pasteCol As String
Dim wsDest As Worksheet
Dim wsSource As Worksheet
'Which column to go to?
pasteCol = "A"
'Where are we going to?
Set wsDest = Worksheets("Results")
'Where are we coming from?
Set wsSource = Worksheets("Sheet1")
Application.ScreenUpdating = False
'Search for the 123 value
With wsSource.Range("A:A")
Set fCell = .Find(what:= ---------- ------------ ---------- -------------- , lookat:=xlWhole, LookIn:=xlValues)
If fCell Is Nothing Then
MsgBox "No values found"
Exit Sub
End If
firstAdd = fCell.Address
Do
pasteRow = wsDest.Cells(.Rows.Count, pasteCol).End(xlUp).Offset(1).Row
If pasteRow > 2 Then pasteRow = pasteRow + 1
fCell.CurrentRegion.Copy wsDest.Cells(pasteRow, pasteCol)
Set fCell = .FindNext(fCell)
Loop Until fCell.Address = firstAdd
End With
Application.ScreenUpdating = True
End Sub
Set fCell = .Find(what:= "---------- ------------ ---------- --------------" , lookat:=xlWhole, LookIn:=xlValues)
Set fCell = .Find(what:= "---" , lookat:=xlPart, LookIn:=xlValues)