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 (892 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 (892 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 (892 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 (892 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
wellsr Q&A is the VBA and Python programming community that rewards you for learning how to code.

Getting Started
VBA Cheat Sheets (On Sale Now)

Earn free prizes for asking VBA and Python questions and for answering questions asked by others in our community.

Looking for something else? Hire our professional VBA Help, instead.

What makes us different?
Our points system rewards you with a chance for free gifts based on the quality of your questions and answers. All you have to do is post and you could get rewarded, like these members:

ParserMonster $25 Amazon Gift Card
Hightree $10 Amazon Gift Card
Thales1 $10 Amazon Gift Card
runfunke $10 Amazon Gift Card
coolag $10 Amazon Gift Card
Siew Hun $10 Amazon Gift Card

So, why don't you join us? It really is an encouraging way to motivate members in our VBA and Python community.


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