I'm using FileDialog to select other workbooks with this. I want to select multiple files at once.
Here is how I do it:
With fd
.Filters.Clear
.Filters.Add "Excel Files", "*.xls; *.xlsx; *.xlsb; *.xltx; *.xltm; *.xlt; *.xml; *.xlam; *.xla; *.xlw", 1
.AllowMultiSelect = True
If .Show = -1 Then
For Each vrtSelectedItem In .SelectedItems
'Extract the Filename (without its file extension) to the File Path
nPath = Mid(vrtSelectedItem, InStrRev(vrtSelectedItem, "\") + 1)
'nPath is Filename with path
nFilename = Left(nPath, InStrRev(nPath, ".") - 1)
If IsWorkBookOpen(vrtSelectedItem) = True Then
MsgBox "File already open."
Else
Set wrkbk = Workbooks.Open("" & vrtSelectedItem)
Set wrkbk_destination = ThisWorkbook '<--- this where is will add the data from files selected with FD
Set wrkbk_source = Workbooks("" & nFilename) '<--- this the selected files
With wrkbk_destination.Sheets("Defect Log")
.Activate
' I want to add the all values within range here but check if data already exist
' For example selected files have data within range of D11 : I11 , D12 : I12 and D13 : I13
' I want to add these but if data within D12 : I12 already exist It will skip adding data and continue with
' D13 : I13
End With
I just need an example of how to do it and I will be the one to point where this added data will be display in wrkbk_destination.