0

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.

prerna arora
  • 75
  • 3
  • 9

2 Answers2

0

Use Application.FileDialog, there are lot's of examples in SO and elsewhere on the internet, for example here

FunThomas
  • 23,043
  • 3
  • 18
  • 34
0

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
jmdon
  • 997
  • 9
  • 17