ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   semicolon delimiter in a cell (https://www.excelbanter.com/excel-programming/330808-semicolon-delimiter-cell.html)

Coco

semicolon delimiter in a cell
 
In a cell I have this values

;1,LPT,23;2,5;DD;5,5;ABC;6,5; etc......

How can I, using VB assign to an array-variable;
(semicolon delimiter ";")

Thanks

Coco



Bob Phillips[_7_]

semicolon delimiter in a cell
 
Dim ary

ary = Split(ActiveCell.Value, ";")

--
HTH

Bob Phillips

"coco" wrote in message
...
In a cell I have this values

;1,LPT,23;2,5;DD;5,5;ABC;6,5; etc......

How can I, using VB assign to an array-variable;
(semicolon delimiter ";")

Thanks

Coco





Dave Peterson[_5_]

semicolon delimiter in a cell
 
Something like...

Option Explicit
Sub testme()

Dim myVal As String
Dim mySplit As Variant
Dim iCtr As Long
myVal = ActiveSheet.Range("a1").Value

mySplit = Split(myVal, ";")
'mySplit = Split97(myVal, ";")

For iCtr = LBound(mySplit) To UBound(mySplit)
Debug.Print iCtr & "--" & mySplit(iCtr)
Next iCtr

End Sub
'from Tom Ogilvy
Function Split97(sStr As String, sdelim As String) As Variant
Split97 = Evaluate("{""" & _
Application.Substitute(sStr, sdelim, """,""") & """}")
End Function

=====
Split was added in xl2k. If you're using xl97, use Tom's Split97.

coco wrote:

In a cell I have this values

;1,LPT,23;2,5;DD;5,5;ABC;6,5; etc......

How can I, using VB assign to an array-variable;
(semicolon delimiter ";")

Thanks

Coco


--

Dave Peterson


All times are GMT +1. The time now is 07:59 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com