View Full Version : Solved: Find "-" position in text
Hello!
How find witch position is "-" in text "30-0,55-16,5" in VBA!!
first i need only the first "-". Later the second "-" also
reason why i need this is dissever the text:
30
0,55
BlueCactus
10-27-2005, 11:38 PM
This will work for two. If you have more than two, you'll soon want a more elegant solution...
myString = "30-0,55-16,5"
firstPos = InStr(myString, "-")
secondPos = InStr(InStr(myString, "-") + 1, myString, "-")
thanks so fast answer http://vbaexpress.com/forum/images/smilies/023.gif
Bob Phillips
10-28-2005, 01:43 AM
This will work for two. If you have more than two, you'll soon want a more elegant solution...
myString = "30-0,55-16,5"
firstPos = InStr(myString, "-")
secondPos = InStr(InStr(myString, "-") + 1, myString, "-")
Without re-inventing the wheel
Sub GetValues()
Dim ary
Dim i As Long
ary = Split(ActiveCell.Value, "-")
For i = LBound(ary) To UBound(ary)
MsgBox ary(i)
Next i
End Sub
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.