+ Reply to Thread
Results 1 to 7 of 7

Excel Macro referencing a variable file name to import

  1. #1
    Registered User
    Join Date
    10-30-2008
    Location
    USA
    Posts
    2

    Excel Macro referencing a variable file name to import

    Hi All

    I have this Macro for Excel which imports 1 file C:\datafiles\user1-data-1.txt into cell E52:


    Please Login or Register  to view this content.
    I'd like to be able to set the file name to import based on the name of excel file that I'm importing data to.


    I.E

    This piece:

    Please Login or Register  to view this content.
    Would become:

    Please Login or Register  to view this content.
    I.E if the Main Excel file name is CoolDoc.xls, the macro imports CoolDoc-data1.txt.


    Thanks!
    -jouell
    Last edited by rylo; 12-08-2008 at 10:24 PM. Reason: code tags and SOLVED

  2. #2
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    10-30-2008
    Location
    USA
    Posts
    2

    Solved!

    Kenneth

    Thank you so much for the quick reply.

    That is AWESOME and this is solved!

    Best
    -jouell

  4. #4
    Registered User
    Join Date
    12-08-2008
    Location
    Orlando
    Posts
    1

    Importing a filename into a cell in a workbook

    I have a similar issue I have been trying to solve. We have a filemaker system that generates an Excel file that contains the job number, Company name and job description. I want to be able to take that file name and put it into cells A1, B1, B3.
    Example Filename: "7658.CompanyX.NewJob.xls'

    Cell A1 = "7658"
    Cell B1 = "CompanyX"
    Cell C1 = "NewJob"

    Can anyone help with this? TIA!

  5. #5
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573
    Welcome to the forum!

    It is best to ask new questions in a new thread. I don't see how your question relates to this thread. Split() is the answer to your question. Post a new thread if you need help with it.

  6. #6
    Registered User
    Join Date
    11-27-2008
    Location
    Manila, Philippines
    Posts
    20

    Wink

    Quote Originally Posted by Kenneth Hobson View Post
    Please Login or Register  to view this content.


    What if my delimiter = '|"

  7. #7
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573
    Please Login or Register  to view this content.
    The best way to learn is to record a macro. This is what the OP did. Select the inserted txt file's data in column A, Data > Text to Column, and set Other to "|".

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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