I separated 2 sub functions (NextStep and AnotherStep) because the SendKeys code will run after the code is done. After I created ImportWorkbooks function, the SendKeys code are now inside a loop, and it will run again after the loop is done.
I used SendKeys because I cannot get the data from the filtered cell. I did my research and somehow SendKeys is the only code that works.
Public Sub ImportWorkbooks()
Dim FNames As Variant
Dim Cnt As Long
Dim Wbk As Workbook
Dim MstWbk As Workbook
Dim Ws As Worksheet
Dim I As Integer
Application.ScreenUpdating = False
Set MstWbk = ThisWorkbook
FNames = Application.GetOpenFilename(FileFilter:="Excel files (*.xls*), *.xls*", MultiSelect:=True)
If Not IsArray(FNames) Then Exit Sub
For Cnt = 1 To UBound(FNames)
Set Wbk = Workbooks.Open(FNames(Cnt))
Wbk.Sheets("Summary").Activate
Wbk.Sheets("Summary").Copy Before:=MstWbk.Sheets(1)
MstWbk.Activate
Application.DisplayAlerts = False
MstWbk.Sheets("Summary").Activate
NextStep
Application.DisplayAlerts = True
Wbk.Close False
Next Cnt
'Application.ScreenUpdating = True
End Sub
Private Sub NextStep()
'set column AV
Range("AV1").Select
ActiveCell.FormulaR1C1 = _"=IFERROR(CONCAT(RC[-9],""_"",ConcatenateButBlank(RC[-3]:RC[-1])),RC[-9])"
Application.CutCopyMode = False
Selection.Copy
Range("AV2").Select
ActiveCell.FormulaR1C1 = "=AGGREGATE(3,3,C[-47]) - 2"
Range("AV3").Select
ActiveCell.FormulaR1C1 = "Status & Date"
Dim Counter As Integer
Dim Total As Integer
Dim I As Integer
Dim RowID As Integer
For Counter = 1 To I
SendKeys "+({DOWN})"
Next Counter
SendKeys "^(v)"
AnotherStep
End Sub
Private Sub AnotherStep()
// VBA code...
End Sub