Results 1 to 3 of 3

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

Threaded View

  1. #1
    Registered User
    Join Date
    02-10-2018
    Location
    Poland
    MS-Off Ver
    2010
    Posts
    7

    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 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
    Do you know a trick how to paste csv-data into an excel spreadsheet keeping the data okay?
    Last edited by michelcr7; 02-10-2018 at 11:39 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Need Code Modification for Text file to Excel File
    By pvsvprasad in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-17-2016, 12:55 PM
  2. Text is shown as General in excel 2010
    By abbassi in forum Excel General
    Replies: 5
    Last Post: 10-17-2014, 03:48 AM
  3. Difference in Excel file Properties - General and Details?
    By garveyarmy in forum Excel General
    Replies: 3
    Last Post: 03-21-2014, 09:35 AM
  4. VBA code for aligning excel file converted from text file.
    By anbub1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-28-2013, 12:44 PM
  5. Code to Export Excel Data to Text File
    By ashkash in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 02-13-2012, 05:59 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. Format: General - Text - General
    By iturnrocks in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-11-2006, 11:50 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