PDA

View Full Version : Solved: separate text using delimiters



dhananjay
12-15-2008, 03:30 AM
I am a newbie to vba!! Pleas tell the function which will split the string based on delimetrs:)
eg:
input:-Dim Sstring, str1,str2,str3,str4,str5, str6 As String
Sstring=T:\ZS_RD_PKG76\Deliverables\07-01212-001.asm.12


Output:
str1=T:
str2=ZS_RD_PKG76
str3=Deliverables
str4=07-01212-001
str5=asm
str6=12

I am running against time.. please:help

Bob Phillips
12-15-2008, 04:00 AM
Dim Sstring As String
Dim str As Variant

Sstring = "T:\ZS_RD_PKG76\Deliverables\07-01212-001.asm.12"
str = Split(Sstring, "\")
MsgBox str(0)
MsgBox str(1)

dhananjay
12-15-2008, 04:16 AM
Thanks mate!!Thanks a ton! :hug:

but I need to remove the number from file name..

Is there a funtion to seperate them
Eg.
Input:07-01212-001.asm.12

Output: 07-01212-001.asm

Bob Phillips
12-15-2008, 04:38 AM
Dim Sstring As String
Dim str As Variant

Sstring = "T:\ZS_RD_PKG76\Deliverables\07-01212-001.asm.12"
str = Split(Replace(Sstring, ".", "\"), "\")
MsgBox str(0)
MsgBox str(1)
MsgBox str(4)
MsgBox str(5)

dhananjay
12-15-2008, 04:53 AM
Thanks a lot mate!!!:friends:

worked like a charm... The following is the modified one which did what i wanted...
Dim Sstring As String
Dim str As Variant

Sstring = "T:\ZS_RD_PKG76\Deliverables\07-01212-001.asm.12"
str = Split(Replace(Sstring, ".", "\"), "\")
Range("a1").Value = str(0)
Range("a2").Value = str(1)
Range("a3").Value = str(3) & "." & str(4)
Range("a4").Value = str(5)


thanks again:content:

Bob Phillips
12-15-2008, 05:08 AM
Dim Sstring As String
Dim str As Variant

Sstring = "T:\ZS_RD_PKG76\Deliverables\07-01212-001.asm.12"
str = Split(Replace(Sstring, ".", "\"), "\")
Range("A1").Resize(UBound(str) - LBound(str) + 1).Value = Application.Transpose(str)