Consulting

Results 1 to 3 of 3

Thread: VBA Code-csv file into excel- from general to text

  1. #1

    VBA Code-csv file into excel- from general to text

    I have a “.csv” file. Now we would like to copy data from this file into another Excel file. Doing this with my simple macro, I encounter a problem in some columns as I have numbers which are stored there in the format: “0000” and “01234567890”. Pasting the data makes then a “0” or “E09” out of the former source.

    If I did that manually, I would do the following:

    1.Copy from .csv file
    2.Paste > “use text import wizard” > changing the respective fields (LFNR_... and EXTERNAL_ID) from “general” to “text”.
    3.Would be happy – everything looks fine

    This is our current macro:

    ImportFileboxData Macro
    '
    Dim dateiname As String
    dateiname = ThisWorkbook.Worksheets("MAS").Range("E7").Value
    '
    ThisWorkbook.FollowHyperlink ThisWorkbook.Worksheets("MAS").Range("E8").Value

    Range("A2:AL10000").Select
    Application.CutCopyMode = False
    Selection.Copy
    Windows("CreateReports.xlsm").Activate
    Sheets("RawData").Select
    Range("A2").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False

    Windows(dateiname).Activate
    ActiveWorkbook.Close (True)

    Windows("CreateReports.xlsm").Activate
    Sheets("MAS").Select




    ß The hyperlink contains the address to where the file is stored
    ß Here the selection of the data from the .csv starts




    ß Here the ‘ordinary’ paste is taking place





    ß into the spreadsheet where the macro button was hitted.

    Do you know a trick how to paste csv-data into an excel spreadsheet keeping the data okay?

  2. #2
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,058
    Location
    Have you by any chance posted this elsewhere?
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  3. #3
    Yes, I shouldn't my mistake

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •