+ Reply to Thread
Results 1 to 4 of 4

Macro to browse for text file and then format it

  1. #1
    Registered User
    Join Date
    09-24-2013
    Location
    Philadelphia
    MS-Off Ver
    Excel 2010
    Posts
    1

    Macro to browse for text file and then format it

    I have a standard text file report of a financial statement that I would like to open in Excel and then format. Each row has a description and then several columns of numbers. I recorded the macro to do this but it embeds the name of the specific file I pointed to when recording it. I'd like the macro to prompt me for a file to open. Then once I select a file, the macro would proceed with the formatting.

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Macro to browse for text file and then format it

    Hi RH4

    Welcome to the Forum!

    Please post the Recorded Code so we can "see" what it is you're trying to do. Be sure to use Code Tags.

    Also, it'll be extremely helpful if you post the Text File you're attempting to Import and Format. Change proprietary information.

    To Attach a File:

    1. Click on Go Advanced
    2. In the frame Attach Files you will see the button Manage Attachments
    3. Click the button.
    4. A new window will open titled Manage Attachments - Excel Forum.
    5. Click the "Add Files"... button to locate your file for uploading.
    6. This will open a new window File Upload...Click "Select Files"
    7. Once you have located the file to upload click the Open button. This window will close.
    8. You are now back in the Manage Attachments - Excel Forum window.
    9. Click the "Upload Files" button and wait until the file has uploaded.
    10. Click the "Done" Button.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  3. #3
    Registered User
    Join Date
    09-27-2011
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    86

    Re: Macro to browse for text file and then format it

    Hi RH4,

    Use the below code:
    __________________________________
    Ipath = Application.GetOpenFilename("Text File (*.txt), *.txt")
    If Ipath = "False" Then
    Exit Sub
    End If
    ______________________________________

    You will be able to browse and pick the file. Then use the Set property to set the Ipath value as text and load in the values. Use your routine format program.

    Regards,
    Loki

  4. #4
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Macro to browse for text file and then format it

    I'd like the macro to prompt me for a file to open.
    Try adding this code snippet at the begining of your macro:

    Please Login or Register  to view this content.
    Alf

+ 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. [SOLVED] Macro to browse for an excel file in a specfic directory
    By lsteinbach in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-27-2012, 12:45 PM
  2. Macro which opens Browse window and pastes the file name to a cell ?
    By keimoon in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-27-2012, 07:54 AM
  3. X-Post: How to format a text file using a macro
    By jkruse in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-04-2012, 03:20 PM
  4. Create a prompt in a macro to "browse for the Source file
    By ggremel in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-08-2011, 04:54 AM
  5. [SOLVED] Opening a browse and load file box in a macro
    By Scott Calkins via OfficeKB.com in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-25-2005, 05:56 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