I've put in the autofilter code to specify the criteria for the copypaste action but not sure whether i've done it correctly or not.
Sub test3()
Dim ws1 As Worksheet, ws2 As Worksheet
Dim copyFrom As Range
Dim lRow As Long
Dim strSearch As String
Set ws1 = Worksheets("sheet1")
strSearch = "LOCAL"
With ws1
'~~> Remove any filters
.AutoFilterMode = False
lRow = .Range("L" & .Rows.Count).End(xlUp).Row
With .Range("L4:L" & lRow)
.AutoFilter Field:=1, Criteria1:="=*" & strSearch & "*"
Set copyFrom = .Offset(1, 0).SpecialCells(xlCellTypeVisible).EntireRow
End With
'~~> Remove any filters
.AutoFilterMode = False
End With
'~~> Destination File
Set ws2 = Worksheets("Sheet2")
With ws2
If Application.WorksheetFunction.CountA(.Cells) <> 0 Then
lRow = .Cells.Find(What:="*", _
After:=.Range("A1"), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row
Else
lRow = 1
End If
copyFrom.Copy .Rows(lRow)
End With
Worksheets("Sheet2").Columns().AutoFit
Cells(1, 1).Activate
End Sub
It is very much appreciated if anyone could highlight what went wrong with the code that i use. Thanks.