Results 1 to 11 of 11
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Import txt in sheet (2000 sr 1)

    In this zip file are present a txt and a wbook.
    in the wbook is present a macro called IMPORT_ARCHIVIO.

    My problem is to import a value from txt file in this mode:

    first string of value
    B6 the value present in the first block of string, C6 the second block of string, ecc... do until the last cell O6

    Next string of value
    B7 the value present in the first block of string, C7 the second block of string, ecc... do until the last cell O7
    i have maked a mcaro but it not work correctly...

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Import txt in sheet (2000 sr 1)

    You have set a password on the code in the workbook, so we can't view the code.

  3. #3
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Import txt in sheet (2000 sr 1)

    21374

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Import txt in sheet (2000 sr 1)

    Try this. It doesn't read the text file line by line, but opens it in Excel, then copies the contents into your table.

    Sub Import_Archivio()
    Dim wbk As Workbook
    Workbooks.OpenText Filename:="E:MACROFASCIANOARCHPROVA.TXT", _
    DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
    ConsecutiveDelimiter:=False, Tab:=True
    Set wbk = ActiveWorkbook
    wbk.Worksheets(1).Range("A1").CurrentRegion.Copy
    ThisWorkbook.Worksheets("LAVORAZ_GIORN").Range("B6 ").PasteSpecial _
    Paste:=xlPasteValues
    Application.CutCopyMode = False
    wbk.Close SaveChanges:=False
    Set wbk = Nothing
    End Sub

  5. #5
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Import txt in sheet (2000 sr 1)

    NATURALLY... U KNOW

    But:

    is possible to transform the serial number present in the txt file in the column D,F,G,H and I in data value...
    If you see in the txt file the block 3,5,6,7 and 8 of string, is a serial data (in this case the block 7 is 0)

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Import txt in sheet (2000 sr 1)

    What is the decimal separator on your system? A point or a comma?

  7. #7
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Import txt in sheet (2000 sr 1)

    ...Comma

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Import txt in sheet (2000 sr 1)

    The text file contains a point as decimal separator. In Excel 2002, you can temporarily change the decimal separator, but that is not possible in Excel 2000. You must either replace the points by commas in the text file, or set your Windows to use the point as decimal separator while running the code.

  9. #9
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Import txt in sheet (2000 sr 1)

    Hum...... i f i have understand i must substituite every point with comma before start a macro?
    If yes, i dont know how to make this, not for me;-) but for you...Naturally

  10. #10
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Import txt in sheet (2000 sr 1)

    Where do the text files come from? Perhaps the person or program that generates the text files can switch to Italian regional settings, so that the files will use the correct decimal separator.

  11. #11
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Import txt in sheet (2000 sr 1)

    Could you open the text file in a text editor and use find/replace in the text editor?

    Steve

Posting Permissions

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