Hi,
I am trying to write one code. In this code, there is one file which I need to activate among the existing open excel files. Also if this file is not found open, I need to open this file from the given location without giving any error(I am not sure how to do this part). The objective is to make the file as active to run further code. Below is the macro code, right now it gives an error.
Please help.
I am trying to write one code. In this code, there is one file which I need to activate among the existing open excel files. Also if this file is not found open, I need to open this file from the given location without giving any error(I am not sure how to do this part). The objective is to make the file as active to run further code. Below is the macro code, right now it gives an error.
Please help.
Code:
Sub copytonewjoinertesting()
' to get data in new joiners report
' need to figure how to open file with the date in its name - learner data report
Dim FName As String
Dim FPath As String
Dim wb1 As ThisWorkbook
Dim wb2 As Workbook
FPath = "C:\Users\aman.bhardwaj\Desktop\Ideas\Learning process\Master files\testing\saved report\"
FName = "LearnersinMandateDataExport_3657_" & Format(Date, "mmddyyyy") & ".xlsx"
Workbooks.Open Filename:=FPath & FName
Set wb1 = ActiveWorkbook
Workbooks.Open ("C:\Users\aman.bhardwaj\Desktop\Ideas\Learning process\Master files\testing\New Joiners_Exceptions Report.xlsx")
Set wb2 = ActiveWorkbook
wb1.Sheets("Sheet1").Select
Range("T1").Select
ActiveSheet.Range(("A1"), Selection.End(xlDown)).AutoFilter Field:=20, Criteria1:="", Operator:=xlAnd
End Sub