+ Reply to Thread
Results 1 to 2 of 2

Issue with parsing text file into worksheet

  1. #1
    Registered User
    Join Date
    05-25-2005
    Posts
    1

    Issue with parsing text file into worksheet

    Hello,

    I have a sub function that goes to a shared drive to grasp a text file, open it and parse it into a worksheet using Delimited. After that, I call a macro that uses "TextToColumns" to parse the column of cells from that worksheet into several columns using FixedWidth. I noticed that the first few digits of some numbers were cut off and put into next cells. To fix it, I went to my codes and manually changed character widths for the columns (arrays below) and it worked for that day. However, the next day, when a new text file comes, the numbers are cutt off again.

    Is there any way to fix this problem? It’s not efficient to manually change code everyday. I apreciate any idea/help. Thanks!

    Here is my code.

    Range("A" & RowNumber & ":A" & RowNumber + 1000).Select

    Selection.TextToColumns Destination:=Range("A" & RowNumber & ":A" & RowNumber + 400), DataType:=xlFixedWidth,
    FieldInfo:=Array(Array(0, 1), Array(11, 1), Array(24, 1), Array(34, 1), Array(50, 1),
    Array(65, 1), Array(79, 1), Array(93, 1), Array(105, 1), Array(119, 1), Array(132, 1),
    Array(147, 1), Array(161, 1), Array(175, 1), Array(187, 1), Array(202, 1), Array(215, 1),
    Array(230, 1), Array(244, 1), Array(257, 1), Array(270, 1)), TrailingMinusNumbers:= True

  2. #2
    Forum Contributor
    Join Date
    11-09-2004
    Posts
    451
    what type of data is it.

    I think fixed width is not a correct option for using text to columns.

    for fixedwidth all the rows should have same width between fields.

    can you paste or attach sample content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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