-
Knowledge Base Approver
The King of Overkill!
VBAX Master
Perhaps I should have asked what you're trying to accomplish?
The following splits a single cell into two parts of an array[vba]Dim tempStr As String, yourArray() As String
tempStr = Range("A1").Text 'cell containing long string
ReDim yourArray(1)
yourArray(0) = Left(tempStr, 3752)
yourArray(1) = Mid(tempStr, 3753)[/vba]
Or if you wanted to have a 2-dimensional array with all cells in a column (for example column A):[vba] Dim yourArray() As String, RG As Range, CellData(), R As Long
Set RG = Intersect(Columns("A"), ActiveSheet.UsedRange)
If RG Is Nothing Then Exit Sub
CellData = RG.Value 'create array of values from usedrange in A
ReDim yourArray(1, UBound(CellData, 1) - 1) 'redim array to be used for split text
For R = 1 To UBound(CellData, 1) 'loop through first column in value array
yourArray(0, R - 1) = Left(CellData(R, 1), 3752)
yourArray(1, R - 1) = Mid(CellData(R, 1), 3753)
Next
'now for each usedcell in column A, yourarray contains (at index X):
' yourarray(0, X) - first 3752 characters of cell
' yourarray(1, X) - remainder of cell starting in character 3753[/vba]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules