0 votes
in VBA by Beginner (5 points)
myfile = Application.GetOpenFilename(, , "Browse for workbook")
Workbooks.Open myfile

myfile = Application.GetOpenFilename(, , "Browse for workbook")
Workbooks.Open myfile

by Expert (916 points)
What's the problem? It is supposed that the workbook you will open will be the active workbook ...
by Beginner (5 points)
yes...the workbook which I open should be the active workbook..i need the code snippet for that..because I will be receiving the data every single day

1 Answer

+1 vote
by Expert (916 points)
selected by
Best answer

Try this code

Sub Test()
    Dim filename As Variant

    filename = Application.GetOpenFilename("Workbooks,*.xlsx,Templates,*.xltx," & _
                                           "Macro-Enabled Workbooks,*.xlsm,Macro-Enabled Templates,*.xltm," & _
                                           "Binary Workbooks,*.xlsb,Excel 97-2003 Workbooks,*.xls," & _
                                           "Excel 97-2003 Templates,*.xlt", 3, "Select File")

    If filename = False Then
        MsgBox "File Not Selected", vbExclamation
        Workbooks.Open filename
    End If
End Sub


by Beginner (5 points)
thank you..how to apply vlook up for two different excel sheets without using macros and the code should be in vba
by Expert (916 points)
You're welcome. I didn't get what you mean!
by Beginner (5 points)
i need to apply the vlook up formula for two different excel sheets
by Expert (916 points)
I suggest posting new thread and put the full details of what you are seeking to .. Put snapshots to your file and put the expected final output

Welcome to wellsr Q&A
Ask any questions you have about VBA and Python and our community will help answer them. wellsr Q&A is the standalone question and answer platform for wellsr.com. If you have a question about one of our specific tutorials, please include a link back to the tutorial.

Getting Started
VBA Cheat Sheets (On Sale Now)

Looking for something else? Hire our team directly through ourVBA Help page, instead.

For more programming tips visit the VBA Tutorials Blog and the Python Tutorials Blog.