Splitting a text field into an array

KenCriss

Active Member
Joined
Jun 6, 2005
Messages
326
I need to read a line from a text file that is 1072197 characters long. I need to split it into an text array that consists of every 80 characters and then put it on a worksheet. I know I have done this before but can't find my code. Any ideas would be appreciated.
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
try

Code:
Option Explicit
Sub Split80()
    Dim Start As Long
    Dim i As Long
    Dim myString As String
    Const Length = 80
    myString =  'populate mystring with file data 
    Start = 1
    For i = 1 To Len(myString) / 80 + 1
        Cells(i, 1) = Mid(myString, Start, 80)
        Start = Start + 80
    Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,715
Members
448,985
Latest member
chocbudda

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top