I want to create a macro that pulls a file by allowing the user to browse and locate the file from his/her local and then perform some functions on the pulled file.
I am not sure how to incorporate the browsing file feature in the macro.
I want to create a macro that pulls a file by allowing the user to browse and locate the file from his/her local and then perform some functions on the pulled file.
I am not sure how to incorporate the browsing file feature in the macro.
The below will open and set wkbFileToOpen, you will then be able to use this as your workbook to manipulate.
Dim vFileToOpen As Variant
Dim wkbFileToOpen As Workbook
'Ask the user to select the file, you can change your desired file extensions and file types
vFileToOpen = Application.GetOpenFilename("Excel Files (*.xls),*.xls,", 1, "Select the workbook", , False)
'if the user cancels, then vFileToOpen will be false, so we need to check there's a value
If Not vFileToOpen Then
Workbooks.Open vFileToOpen
Set wkbFileToOpen = ActiveWorkbook
End If