Solved

VBA Excel 2016 - Modify Filedialog using cell reference

Posted on 2016-07-28
2
35 Views
Last Modified: 2016-07-28
I need to change the filedialog code to reference a cell in my workbook.  I would like to change ChDir = G3, what is the correct syntax.

Public Function Open_FileDialog()
Dim tmpFile

    ChDrive "S:\" 'change the drive also
    ChDir "S:\Corp Accts\Country\Invoices\"

    DoEvents

    tmpFile = Application.GetOpenFilename(FileFilter:="Microsoft Excel Files (.xls),.xls")

    If tmpFile <> False Then
        Workbooks.Open FileName:=tmpFile
    End If
End Function

Open in new window

0
Comment
Question by:Karen Schaefer
2 Comments
 
LVL 48

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 41733425
Hi,

pls try

Public Function Open_FileDialog()
Dim tmpFile

    ChDrive "S:\" 'change the drive also
    ChDir Range("G3").Value
    DoEvents

    tmpFile = Application.GetOpenFilename(FileFilter:="Microsoft Excel Files (.xls),.xls")

    If tmpFile <> False Then
        Workbooks.Open FileName:=tmpFile
    End If

Open in new window

0
 

Author Closing Comment

by:Karen Schaefer
ID: 41733462
thanks
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now