CarlStephens
Board Regular
- Joined
- Sep 25, 2020
- Messages
- 128
- Office Version
- 2016
- Platform
- Windows
Hello Everyone,
I have the below code that basically searches for required information on one sheet and then pastes it onto another sheet when it finds it, however, there arent always new information to paste across and I am wondering whether there is a code to add to the below that when there is no new information to copy and paste across that a message box will appear to say "No new employee records found" - is this possible? Thank you.
I have the below code that basically searches for required information on one sheet and then pastes it onto another sheet when it finds it, however, there arent always new information to paste across and I am wondering whether there is a code to add to the below that when there is no new information to copy and paste across that a message box will appear to say "No new employee records found" - is this possible? Thank you.
VBA Code:
Sub CoypFilteredData()
Dim wsData As Worksheet
Dim wsDest As Worksheet
Dim lr As Long
Application.ScreenUpdating = False
Set wsData = Worksheets("1. MAPS List")
Set wsDest = Worksheets("2. Joiners List")
wsData.Unprotect ("ML")
lr = wsData.Cells(Rows.Count, "AP").End(xlUp).Row
If wsData.FilterMode Then wsData.ShowAllData
With wsData.Rows(1)
.AutoFilter Field:=42, Criteria1:="Not On Joiners List"
.AutoFilter Field:=43, Criteria1:="<90"
If wsData.Range("H1:H" & lr).SpecialCells(xlCellTypeVisible).Cells.Count > 1 Then
wsData.Range("AR2:AU" & lr).SpecialCells(xlCellTypeVisible).copy
wsDest.Range("AC" & Rows.Count).End(3)(2).PasteSpecial Paste:=xlPasteValues
wsDest.Select
End If
.AutoFilter Field:=42
.AutoFilter Field:=43
Range("AP1").Select
wsData.EnableAutoFilter = True
wsData.Protect Password:="ML", UserInterfaceOnly:=True
End With
Application.ScreenUpdating = True
End Sub
Last edited by a moderator: