Results 1 to 9 of 9

Import excel file

Threaded View

JeDD21 Import excel file 09-09-2018, 10:24 AM
JeDD21 Re: Import excel file 09-10-2018, 08:49 AM
JeDD21 Re: Import excel file 09-11-2018, 04:36 AM
jindon Re: Import excel file 09-11-2018, 08:32 AM
JeDD21 Re: Import excel file 09-11-2018, 09:55 AM
jindon Re: Import excel file 09-11-2018, 10:15 AM
JeDD21 Re: Import excel file 09-11-2018, 11:02 AM
JeDD21 Re: Import excel file 09-12-2018, 09:58 AM
jindon Re: Import excel file 09-12-2018, 10:02 AM
  1. #1
    Registered User
    Join Date
    04-26-2017
    Location
    München
    MS-Off Ver
    MS office 2013
    Posts
    28

    Import excel file

    Hello,

    i am using this code to import a csv file to an existing excel file. This works fine, but now i want to do something different. i have 2 excel sheets with information i want to import. After clicking on the button a windows explorer window should be opened, there i can select the file i need. In the first Column, of the excel sheet with the values i want to import, there are articels which can be ordered, in the second there is a order number and in the fifth there is the price. I dont need the other information, so i have thought to import only column A, B and E. The code here should do it, but there is an error i haven't found it yet. The price of the articles are in the form 23,3. After importing the comma should be replaced by a point (23.3). But its a date for excel, so i dont know how i can do this. Mark the column as a text doesn't help here.


    Sub test()
        Dim fn As String, cn As Object, rs As Object
        fn = Application.GetOpenFilename("xlsxFiles,*.xlsx")
        If fn = "False" Then Exit Sub
        Set cn = CreateObject("ADODB.Connection")
        Set rs = CreateObject("ADODB.Recordset")
        With cn
            .Provider = "Microsoft.Jet.OLEDB.4.0"
            .Properties("Extended Properties") = "Text;HDR=YES;FMT=Delimited;"
            .Open Left$(fn, InStrRev(fn, "\"))
        End With
        rs.Open "Select F1, F2, F5 from `" & Mid$(fn, InStrRev(fn, "\") + 1) & "`", cn, 3, 3
        Range("a" & Rows.Count).End(xlUp)(3).Value = fn
        Range("a" & Rows.Count).End(xlUp)(2).CopyFromRecordset rs
        Set rs = Nothing: Set cn = Nothing
    End Sub
    I would be thankful for any help.

    regards
    Jedd21
    Attached Files Attached Files
    Last edited by JeDD21; 09-11-2018 at 07:32 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Import CSV file in Excel using ADODB when values in the file have double quotes
    By buran in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-23-2015, 12:51 PM
  2. Import data from Excel file into filtered cells in another Excel file
    By Rebecca12 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-14-2012, 04:05 PM
  3. File name without file path (data import) - Excel crash
    By exinx in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-19-2012, 02:08 AM
  4. VBA: Import CSV file into an Excel Workbook with user defined file name and directory
    By LarryLegend in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-18-2012, 04:47 AM
  5. File import - select file and import sheet(1) from closed workbook
    By Armitage2k in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-22-2011, 03:15 AM
  6. VBA code to import text file to the fixed excel file
    By wangdian in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-30-2010, 10:13 AM
  7. Replies: 0
    Last Post: 08-10-2010, 07:00 AM

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