Hello All,
I have an excel function that I'm using to aggregate a bunch of files into a single excel sheet. Right now it's hard coded to pull from a specific folder location, but I would like a user to be able to select the area where the excel files are located. Can anyone assist?
I have an excel function that I'm using to aggregate a bunch of files into a single excel sheet. Right now it's hard coded to pull from a specific folder location, but I would like a user to be able to select the area where the excel files are located. Can anyone assist?
PHP:
Sub ImportGroups()
Dim fPATH As Variant, fNAME As String
Dim LR As Long, NR As Long
Dim wbGRP As Workbook, wsDEST As Worksheet
Application.ScreenUpdating = False
Set wsDEST = ThisWorkbook.Sheets("Summary")
NR = wsDEST.Range("B" & Rows.Count).End(xlUp).Row + 1
fPATH = "Folder path" 'folder path would normally be inserted here
fNAME = Dir(fPATH & "*.xls") 'get the first filename in fpath
Do While Len(fNAME) > 0
Set wbGRP = Workbooks.Open(fPATH & fNAME) 'open the file
LR = Range("B" & Rows.Count).End(xlUp).Row 'how many rows of info?
If LR > 1 Then
Range("A8:BF" & LR).Copy wsDEST.Range("A" & NR)
NR = wsDEST.Range("B" & Rows.Count).End(xlUp).Row + 1
End If
wbGRP.Close False 'close data workbook
fNAME = Dir 'get the next filename
Loop
End Function