I am very new to creating excel Macro.
Please suggest me how to save and close the excel after running macro. I am using this VBA macro for concatenate more than 70 + excel files. It is difficult to save and close such big number of files at one time.
It would me grateful if you could provide me a solution.
Sub LoopThroughFiles()
FolderName = "C:\Users\Aravindh sandhya .LAPTOP-E6MTP0NR\Desktop\CONCATENATE VB\CONCATENATE"
If Right(FolderName, 1) <> Application.PathSeparator Then FolderName = FolderName & Application.PathSeparator
Fname = Dir(FolderName & "*.xls")
'loop through the files
Do While Len(Fname)
With Workbooks.Open(FolderName & Fname)
Dim LastRow As Long
LastRow = Cells(Rows.Count, "D").End(xlUp).Row
Range("H1:H" & LastRow) = Evaluate(Replace("D1:D#&"" , ""&E1:E#&"" , ""&F1:F#&"", ""&G1:G#", "#", LastRow))
LastRow = Cells(Rows.Count, "M").End(xlUp).Row
Range("O1:O" & LastRow) = Evaluate(Replace("M1:M#&"" OF ""&N1:N#", "#", LastRow))
End With
' go to the next file in the folder
Fname = Dir
Loop
End Sub