Results 1 to 8 of 8

Text to Columns Fixed Width Using Predefined Lengths

Threaded View

  1. #1
    Registered User
    Join Date
    02-03-2012
    Location
    CA
    MS-Off Ver
    Excel 2007
    Posts
    4

    Text to Columns Fixed Width Using Predefined Lengths

    Hi Everyone,

    I was hoping you could help me solve a problem. I'm trying to make a macro that will turn a fixed length text file into columns. So I Googled around and found this piece of code that works:

    Sub MySplit()
    Columns(1).TextToColumns Destination:=Range("A1"), DataType:=xlFixedWidth, _
    FieldInfo:=Array(Array(0, 1), Array(4, 1), Array(12, 1), Array(19, 1), _
    Array(24, 1))
    End Sub
    I want to take it a step further. Often times, I know the position of where to split beforehand. So rather than having to manually type that it in every time, I want excel to pass an array of position values into the text to columns splitter. Is this possible? I imagine it would look something like this.

    Sub MySplit()
    myArray = range("R65:R125") 'My list of position values
    Columns(1).TextToColumns Destination:=range("A1"), DataType:=xlFixedWidth, FieldInfo:=myArray()
    End Sub
    I've been trying for the last two hours, and it's been driving me crazy

    Any help would be greatly appreciated.
    Last edited by easycompany16; 02-04-2012 at 12:13 AM.

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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