Dim contents As String ' contents of cell
Dim curcell As String ' current cell
Sub movenext()
Range("A1").Select
Selection.Copy
contents = Range("A1").Text
Do Until contents = ""
curcell = ActiveCell.Address
Selection.Copy
contents = ActiveCell.Text
Call Macro1
ActiveCell.Offset(1, 0).Activate ' down
Loop
MsgBox ("last row checked")
End Sub
Sub Macro1()
On Error GoTo errorhandler
Columns("B:B").Select
Selection.Find(What:=contents, After:=ActiveCell, LookIn:=xlFormulas, Lookat _
:=xlPart, searchorder:=xlByRows, searchdirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
Range(curcell).Select
errorhandler:
Select Case Err
Case 91
Call findlastrow
Resume Next
End Select
End Sub
Sub findlastrow()
Dim c As Object
' c.row is the number of the last row
Dim target As String
Dim num As String
num = 1
With Sheets("Sheet1").Range("b:b")
Set c = .Find(What:="*", LookIn:=xlValues, Lookat:=xlPart, searchorder:=xlByRows, searchdirection:=xlPrevious)
End With
target = c.Row + num ' helps to move to next free ro in column B
Range("B" & target).Select
ActiveSheet.Paste
With Selection.Font
' .Name = "Arial"
' .FontStyle = "Regular"
' .Size = 10
' .Strikethrough = False
' .Superscript = False
' .Subscript = False
' .OutlineFont = False
' .Shadow = False
' .Underline = xlUnderlineStyleNone
.ColorIndex = 3 ' makes pasted text red
End With
End Sub