Macro to open file search window, open file, then run code

  • Hi all,

    I've written code that does exactly what I want it to do. I have a drop down that when I select a particular field it will run a particular code ive written (by Val target code within the sheet).

    The code runs fine, however, I would like to once I select a particular field from the drop down open up to search for the file in "my computer", the user can then manually search for the file and then open it, then VBA could take the necessary information from that spreadsheet and then run my code.

    At the moment, I am manually copying and pasting the data from the source spreadsheet to my macro template. This is the manual process I want to automate.

    any clues on where I can find this code or if someone has a good example?

    thanks all

  • Re: Macro to open file search window, open file, then run code

    Try this !

    Sub GetFile()
    Dim fNameAndPath As Variant
    fNameAndPath = Application.GetOpenFilename(FileFilter:="Excel Files (*.XLS), *.XLS", Title:="Select File To Be Opened")
    If fNameAndPath = False Then Exit Sub
    Workbooks.Open Filename:=fNameAndPath
    End Sub

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!