+ Reply to Thread
Results 1 to 5 of 5

Import txt, csv, xls files into excel using vba

  1. #1
    Registered User
    Join Date
    05-02-2023
    Location
    Long Island
    MS-Off Ver
    2019
    Posts
    3

    Exclamation Import txt, csv, xls files into excel using vba

    I've been trying to open text files into excel using vba. I want to access any text, csv, xls file and import it fast by clicking one button (located on the top of "Dust Raw Data" and "VOC Raw Data" worksheets - see attached. I generated a vba code, but the issue is that when I run the code (press the import button - on the Dust Raw and VOC Raw sheets), the values containing numbers do not register and they are assumed as text instead of numbers. Additionally, I want to extract the time only from the VOC Raw Data sheet (using the PID txt file- see attached) to the "VOC table" sheet which must be in the format of hh:mm AM/PM, but instead; excel gives me as m/d/yyyy h:mm. Excel cannot understand what I`m trying to achieve so it copies the whole thing as Ex: 05/01/23 06:05:55 instead of 6:05 AM. Please let me know if I need to add more to my code and if so, what lines. TIA!!

    (Note: I`m aware of power query, but I want to use vba in this particular case)

    The VBA Code:

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by dagamerjc; 05-02-2023 at 01:04 PM. Reason: Code formatting

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,869

    Re: Import txt, csv, xls files into excel using vba

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between [code]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/code] tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (Note: this change is not optional. As you are new here, I have done it for you this time.)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    05-02-2023
    Location
    Long Island
    MS-Off Ver
    2019
    Posts
    3

    Re: Import txt, csv, xls files into excel using vba

    Thank you for letting me know!

  4. #4
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Import txt, csv, xls files into excel using vba


    Elaborate clearly with details what to import from the print text file - obviously not designed to be imported ! - and
    where the result must be located in the workbook …

  5. #5
    Registered User
    Join Date
    05-02-2023
    Location
    Long Island
    MS-Off Ver
    2019
    Posts
    3

    Re: Import txt, csv, xls files into excel using vba

    Thanks for the feedback. I made it a bit clearer (I hope)!

+ 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. Import two txt files in excel and highlights the differece b/w two files data
    By Imran/CVT in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-27-2019, 03:43 AM
  2. Iterative process to import multiple text files into multiple excel files
    By Ecth3lion in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-29-2018, 01:04 PM
  3. How to Import pdf files in to excel.
    By Muhammad Shafique in forum Excel General
    Replies: 1
    Last Post: 09-02-2014, 02:13 AM
  4. 30 excel files, two cells to import!
    By jakethemuss in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-20-2007, 08:51 AM
  5. is it possible to import rtf files into Excel?
    By Teulia in forum Excel General
    Replies: 0
    Last Post: 08-18-2006, 10:05 AM
  6. [SOLVED] How do I import several csv files into one excel worksheet?
    By chieftrain in forum Excel General
    Replies: 10
    Last Post: 06-06-2006, 03:18 AM
  7. [SOLVED] HELP: Import several TXT files into Excel
    By luis in forum Excel General
    Replies: 6
    Last Post: 04-09-2006, 04:20 PM

Tags for this Thread

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