+ Reply to Thread
Results 1 to 12 of 12

Workbook.open a filename with path and cell value in it

  1. #1
    Registered User
    Join Date
    06-11-2010
    Location
    The Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    81

    Workbook.open a filename with path and cell value in it

    I am trying the following:

    Please Login or Register  to view this content.
    If cell J2 has value/text: test

    and I run the macro it states "O:\Splitsen\.xlsx not found". While it should open workbook O:\Splitsen\test.xlsx

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Workbook.open a filename with path and cell value in it

    Replace this line

    Please Login or Register  to view this content.
    With

    Please Login or Register  to view this content.


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,528

    Re: Workbook.open a filename with path and cell value in it

    Is the word "test", without quotes, indeed in cell J2?
    Your code works for me but if cell J2 in the ActiveSheet (visible sheet when you run the macro) is empty I get the warning you mentioned

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Workbook.open a filename with path and cell value in it

    On which sheet does J2 hold the filename?
    If posting code please use code tags, see here.

  5. #5
    Registered User
    Join Date
    06-11-2010
    Location
    The Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    81

    Re: Workbook.open a filename with path and cell value in it

    Complete script is:
    Please Login or Register  to view this content.
    The two lines in red have the text "TEST" stated but I want to change those to the text selected in cell J2.

    @Norie sheet name and file name are is marked blue above.
    Last edited by dutchmaste; 06-16-2016 at 08:10 PM.

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Workbook.open a filename with path and cell value in it

    That code is kind of like different than the original code you posted.

  7. #7
    Registered User
    Join Date
    06-11-2010
    Location
    The Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    81

    Re: Workbook.open a filename with path and cell value in it

    At time of opening this thread I thought it was just a problem with this line. But the questions made me think maybe it is something somewhere else in the script.

    Only difference is between first code and the line in the complete code is:
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

  8. #8
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: Workbook.open a filename with path and cell value in it

    OK but the Range("J2") with TEST in it is it on Sheet Data or HS Lijst ? And which Workbook ?
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  9. #9
    Registered User
    Join Date
    06-11-2010
    Location
    The Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    81

    Re: Workbook.open a filename with path and cell value in it

    J2 is located in workbook "SPLITSEN_v1.0g.xlsm" and on worksheet "HS lijst"

  10. #10
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: Workbook.open a filename with path and cell value in it

    So something like this should work.
    Please Login or Register  to view this content.
    And do you really need to copy an entire worksheet ?

  11. #11
    Registered User
    Join Date
    06-11-2010
    Location
    The Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    81

    Re: Workbook.open a filename with path and cell value in it

    Works like a charm, thank you so much. No more painkillers for my headache.

  12. #12
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: Workbook.open a filename with path and cell value in it

    You're welcome and thanks for the rep.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Find filename and path of a linked file in another cell
    By Tsangman007 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-02-2015, 01:35 AM
  2. Value from another open workbook in filename
    By biznez in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-23-2015, 03:40 PM
  3. Using Workbook.Open Filename to Open a Cell Reference Filename
    By PerplexedMel in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-10-2014, 12:20 PM
  4. [SOLVED] Save a workbook to a folder path in textbox2 using textbox1 as filename
    By yoko21 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-24-2013, 03:59 AM
  5. Replies: 3
    Last Post: 07-09-2012, 03:09 PM
  6. Find filename, path, document size, filename length and path length?
    By Laneyboggs in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-30-2010, 08:01 PM
  7. Use cell in open workbook to id path to wanted data
    By NickiName in forum Excel General
    Replies: 3
    Last Post: 05-10-2007, 02:04 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1