+ Reply to Thread
Results 1 to 13 of 13

How to Import only specific colounms from CSV file

  1. #1
    Registered User
    Join Date
    03-09-2020
    Location
    Denmark
    MS-Off Ver
    2013
    Posts
    9

    How to Import only specific colounms from CSV file

    Hi ,
    I am new here and with VBA as well and I really need some help how to do below challange.
    I have found below file to import all CSV files in a folder and it works, but....What I really need is that the VBA code only copys out colounm K,L,R and S from the CSV files in the folder
    and place it from colounm A1 to D2000.

    And if it is possible maby show a list of all the imported files without the hole filePath so only the file(s) name(s) are shown in the msgbox.

    I really appreciate if someone can help me out to solve this for me very big issue.

    With thanks,
    Denmark

    PS
    My CSV files are semicolon separated.


    Please Login or Register  to view this content.
    Last edited by Denmark; 10-05-2020 at 03:02 PM.

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Import only specific colounms from CSV file

    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 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. No help to be offered until this moderation request has been fulfilled.)
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Registered User
    Join Date
    03-09-2020
    Location
    Denmark
    MS-Off Ver
    2013
    Posts
    9

    Re: Import only specific colounms from CSV file

    mehmetcik
    Sorry, as I said I´m new but I´ll try again hopfull that I have understand that you mean.

  4. #4
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Import only specific colounms from CSV file

    Code Tags

    Hopefully a moderator will add the code tags for you.

    No One can help until they are added. Which is frustrating for us as well as to you.


    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found at http://www.excelforum.com/forum-rule...rum-rules.html

  5. #5
    Registered User
    Join Date
    03-09-2020
    Location
    Denmark
    MS-Off Ver
    2013
    Posts
    9

    Re: Import only specific colounms from CSV file

    mehmetcik,
    Thank you, I think I understood what you meant by tags.

  6. #6
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,286

    Re: How to Import only specific colounms from CSV file

    If I understand correctly

    try change
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    03-09-2020
    Location
    Denmark
    MS-Off Ver
    2013
    Posts
    9

    Re: How to Import only specific colounms from CSV file

    Hi nigelog,
    Thanks for your replay. I have tried your suggestion but I´ve got an compile error "For each control variable must be variant or Object".
    What am I doing wrong??

  8. #8
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,286

    Re: How to Import only specific colounms from CSV file

    I dont have the workbook or input csv files so not tested

    Try
    Please Login or Register  to view this content.
    at second look you are going to have to try emulate this process into your code

    Please Login or Register  to view this content.
    Last edited by nigelog; 10-06-2020 at 12:32 PM.

  9. #9
    Registered User
    Join Date
    03-09-2020
    Location
    Denmark
    MS-Off Ver
    2013
    Posts
    9

    Re: How to Import only specific colounms from CSV file

    Hi nigelog,
    jep the først and the second fil do not work. It gives desame error.
    I will tomorrow try the third code you send. My biggest challange is to figer out how the code exactly works, as VBA still is very new for me.

  10. #10
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,670

    Re: How to Import only specific colounms from CSV file

    Try
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    03-09-2020
    Location
    Denmark
    MS-Off Ver
    2013
    Posts
    9

    Re: How to Import only specific colounms from CSV file

    Hi Jindon,
    Thank you very very much - your code works perfectly
    Just one last question to your code. There is a empty row between each file and headers names from the following importes files - How do I get rid of this empty row(s) and headers between each file, so I only keep the headers from the first imported file in colounm 1 ?
    Last edited by Denmark; 10-07-2020 at 03:32 PM.

  12. #12
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,670

    Re: How to Import only specific colounms from CSV file

    File might have extra carriage return at the end....

    Try change to
    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    03-09-2020
    Location
    Denmark
    MS-Off Ver
    2013
    Posts
    9

    Re: How to Import only specific colounms from CSV file

    Hi Jindon,
    many many greatful thanks for your help. It works fantastic.

+ 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. Macro to import .txt file into specific worksheet
    By Phil_Ford in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-23-2017, 02:21 PM
  2. Import specific data from another excel file?
    By devensonas in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-27-2014, 08:56 AM
  3. how to import specific row from a txt file into excel using macro ?
    By kumar77 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-01-2013, 07:07 AM
  4. [SOLVED] Import text file from specific folder
    By Ricker090 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 07-07-2012, 09:08 PM
  5. Import specific sheets from different file.
    By fatalcore in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-27-2011, 09:44 AM
  6. macro to import specific sheets with value in a file
    By aravindhan_31 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-04-2009, 10:55 AM
  7. Import selected file to specific sheet
    By jnate in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-02-2009, 09:41 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