'VBA Inserting Cell with Browsing File

Sub selectFile()

'Create and set dialog box as variable
Dim dialogBox As FileDialog
Set dialogBox = Application.FileDialog(msoFileDialogOpen)

'Do not allow multiple files to be selected
dialogBox.AllowMultiSelect = False

'Set the title of of the DialogBox
dialogBox.Title = "Select a file"

'Set the default folder to open
dialogBox.InitialFileName = "C:\Users\Downloads"

'Clear the dialog box filters
dialogBox.Filters.Clear


'Show the dialog box and output full file name
If dialogBox.Show = -1 Then
    ActiveSheet.Range("filePath").Value = dialogBox.SelectedItems(1)
End If

End Sub

I am trying select different file for different cell. I try range, but it still only allow me to select one file for the all the cell in that range. Can someone help me with this. Thanks in advance. This code is from https://exceloffthegrid.com/insert-file-path-into-cell-with-browse-button/

Thanks Tim for reminding me to put up the source. I am not very familiar with the posting policy. Sorry about that



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source