Can I replicate the SPLIT function in Excel 97?

sts023

Board Regular
Joined
Sep 1, 2008
Messages
106
Sorry if this is a mind-numbingly stupid question, but does anyone have any code to replicate the SPLIT function?
I'm running on Excel 97, which dislikes SPLIT intensely!

Thanks in advance....
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Richard....

Thanks for the help - I suspect it may even worK! ;)

Although I've been in IT for probably longer than you've existed, I have to admit to having been into VBA for nearly half an hour now, so some of my comments may appear to be somewhat inexperienced!

I think I get the general gist of what's happenning - set up a formula to execute a function, then execute it on the input, then copy the results to the output array.
I'm not sure what the line "Split = aryValues" is doing, unless it's a recursive call?

I presume the code you've kindly offered is invoked by something like
Split(Inputline,"~") in my other (equally plagiarised) VBA, (I'm splitting at the tilda char) and puts it's results in
aryValues(x)

Can you refer me to something which explains (in English to a simpleton) the parameters to Evaluate ? It looks promising/exciting/beyond me....


Steve
 
Upvote 0
Here Userfunction for 97

Code:
Function Split97(r, Optional u As String = ",")
Dim MidStr     As Variant
Dim AnsStr     As Variant
ReDim MidStr(0 To Len(r))
Dim i As Double, j As Double
Dim GetText, GetPoss
GetText = r
For i = 1 To Len(r)
GetPoss = InStr(GetText, u)
     If GetPoss > 0 Then
          MidStr(j) = Left(GetText, GetPoss - 1)
          GetText = Mid(GetText, GetPoss + 1)
          j = j + 1
     Else
          MidStr(j) = Mid(GetText, GetPoss + 1)
          Exit For
     End If
Next
ReDim AnsStr(j)
For i = 0 To j
     AnsStr(i) = MidStr(i)
Next
Split97 = AnsStr
End Function

Sub test()
Dim t As String
t = "a~b~~c~dd"
Range("a7").Resize(2, 7) = Split97(t, "~")
End Sub

same answer Split
 
Upvote 0
The service you guys give freely is awesome!

Not only am I getting answers, I'm learning at the same time!!!

I'll now hibernate for a time, whilst happily crashing Excel with my bumbling attempts to understand, customise, and implement these code offerings....
 
Upvote 0

Forum statistics

Threads
1,214,606
Messages
6,120,479
Members
448,967
Latest member
visheshkotha

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