Link to home
Start Free TrialLog in
Avatar of Seamus2626
Seamus2626Flag for Ireland

asked on

open file vba

Hi,

I have some code to open a file using VBA

    ChDir "R:\ABC\Boris Info\Horis_Project\GBM\Dec-15\Flat Data Files"
    Workbooks.Open Filename:= _
        "R:\ABC\Boris Info\Horis_Project\GBM\Dec-15\Flat Data Files\Flat_GBM_ALL.xlsx"
    ActiveWindow.ActivateNext

I have a drop down in cell D4 which has months Jan-16, Feb-16 etc

Instead of hardcoding Dec-15 like above, can the code use whatever value is in D4 so each month it selects the correct file

Thanks
Avatar of Flora Edwards
Flora Edwards
Flag of Sweden image

you can use "R:\ABC\Boris Info\Horis_Project\GBM\"&Range("D4").value&"\Flat Data Files"
Avatar of Seamus2626

ASKER

getting the red errors when i paste that in place of dec-15
ASKER CERTIFIED SOLUTION
Avatar of Subodh Tiwari (Neeraj)
Subodh Tiwari (Neeraj)
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Perfect!
Avatar of Professor J
Professor J

weldone Sktneer
Thanks Professor! :)

@Seamus2626
Thanks. Glad it worked for you.