Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
PCC PCC is offline
external usenet poster
 
Posts: 6
Default VBA SPLIT FUNCTION

I need to get the left portion of a variable length string
up to the comma delimiter. I tried the Split function but
apparently I'm not getting it right.
For Example:

Ex1:
The string: "Duck, Donald - 8765"
I want to get "Duck"

Ex2:
The String: "Mouse, Mickey - 3456"
I want to get "Mouse"
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default VBA SPLIT FUNCTION

Dim str As String
str = "Duck, Donald"
MsgBox Left(str, InStr(str, ",") - 1)

"PCC" wrote in message
...
I need to get the left portion of a variable length string
up to the comma delimiter. I tried the Split function but
apparently I'm not getting it right.
For Example:

Ex1:
The string: "Duck, Donald - 8765"
I want to get "Duck"

Ex2:
The String: "Mouse, Mickey - 3456"
I want to get "Mouse"



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default VBA SPLIT FUNCTION

Hi
try
sub foo()
Dim str As String
v_str = "Duck, Donald - 8765"
MsgBox Left(v_str, InStr(v_str, ",") - 1)

end sub

--
Regards
Frank Kabel
Frankfurt, Germany


PCC wrote:
I need to get the left portion of a variable length string
up to the comma delimiter. I tried the Split function but
apparently I'm not getting it right.
For Example:

Ex1:
The string: "Duck, Donald - 8765"
I want to get "Duck"

Ex2:
The String: "Mouse, Mickey - 3456"
I want to get "Mouse"

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 690
Default VBA SPLIT FUNCTION

If you wish to use the Split function, here is one way...

Sub Demo()
Dim s As String
s = "Duck, Donald - 8765"
Debug.Print Split(s, ",")(0)

s = "Mouse, Mickey - 3456"
Debug.Print Split(s, ",")(0)
End Sub

returns:
Duck
Mouse

--
Dana DeLouis
Using Windows XP & Office XP
= = = = = = = = = = = = = = = = =


"PCC" wrote in message
...
I need to get the left portion of a variable length string
up to the comma delimiter. I tried the Split function but
apparently I'm not getting it right.
For Example:

Ex1:
The string: "Duck, Donald - 8765"
I want to get "Duck"

Ex2:
The String: "Mouse, Mickey - 3456"
I want to get "Mouse"



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default VBA SPLIT FUNCTION

Don't know what the split function is except to split windows.

One way is to use InStr and search for the comma to get it's position, then
use the LEFT function to extract that many characters - 1.

TH

On 4/16/04 8:38, in article , "PCC"
wrote:

I need to get the left portion of a variable length string
up to the comma delimiter. I tried the Split function but
apparently I'm not getting it right.
For Example:

Ex1:
The string: "Duck, Donald - 8765"
I want to get "Duck"

Ex2:
The String: "Mouse, Mickey - 3456"
I want to get "Mouse"




  #6   Report Post  
Posted to microsoft.public.excel.programming
PCC PCC is offline
external usenet poster
 
Posts: 6
Default VBA SPLIT FUNCTION

My first time using this passport.
It's great and so is your response
thanx a lot
-----Original Message-----
Dim str As String
str = "Duck, Donald"
MsgBox Left(str, InStr(str, ",") - 1)

"PCC" wrote in

message
...
I need to get the left portion of a variable length

string
up to the comma delimiter. I tried the Split function

but
apparently I'm not getting it right.
For Example:

Ex1:
The string: "Duck, Donald - 8765"
I want to get "Duck"

Ex2:
The String: "Mouse, Mickey - 3456"
I want to get "Mouse"



.

  #7   Report Post  
Posted to microsoft.public.excel.programming
PCC PCC is offline
external usenet poster
 
Posts: 6
Default VBA SPLIT FUNCTION

My first time using this passport.
It's great and so is your response
thanx a lot
-----Original Message-----
If you wish to use the Split function, here is one way...

Sub Demo()
Dim s As String
s = "Duck, Donald - 8765"
Debug.Print Split(s, ",")(0)

s = "Mouse, Mickey - 3456"
Debug.Print Split(s, ",")(0)
End Sub

returns:
Duck
Mouse

--
Dana DeLouis
Using Windows XP & Office XP
= = = = = = = = = = = = = = = = =


"PCC" wrote in

message
...
I need to get the left portion of a variable length

string
up to the comma delimiter. I tried the Split function

but
apparently I'm not getting it right.
For Example:

Ex1:
The string: "Duck, Donald - 8765"
I want to get "Duck"

Ex2:
The String: "Mouse, Mickey - 3456"
I want to get "Mouse"



.

  #8   Report Post  
Posted to microsoft.public.excel.programming
PCC PCC is offline
external usenet poster
 
Posts: 6
Default VBA SPLIT FUNCTION

My first time using this passport.
It's great and so is your response
thanx a lot
-----Original Message-----
Hi
try
sub foo()
Dim str As String
v_str = "Duck, Donald - 8765"
MsgBox Left(v_str, InStr(v_str, ",") - 1)

end sub

--
Regards
Frank Kabel
Frankfurt, Germany


PCC wrote:
I need to get the left portion of a variable length

string
up to the comma delimiter. I tried the Split function

but
apparently I'm not getting it right.
For Example:

Ex1:
The string: "Duck, Donald - 8765"
I want to get "Duck"

Ex2:
The String: "Mouse, Mickey - 3456"
I want to get "Mouse"

.

  #9   Report Post  
Posted to microsoft.public.excel.programming
PCC PCC is offline
external usenet poster
 
Posts: 6
Default VBA SPLIT FUNCTION

It works
thank you...thank you...thank you... alot
-----Original Message-----
Don't know what the split function is except to split

windows.

One way is to use InStr and search for the comma to get

it's position, then
use the LEFT function to extract that many characters - 1.

TH

On 4/16/04 8:38, in article 1d7f601c423c0$7bc11180

, "PCC"
wrote:

I need to get the left portion of a variable length

string
up to the comma delimiter. I tried the Split function

but
apparently I'm not getting it right.
For Example:

Ex1:
The string: "Duck, Donald - 8765"
I want to get "Duck"

Ex2:
The String: "Mouse, Mickey - 3456"
I want to get "Mouse"


.

  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default VBA SPLIT FUNCTION

xl2k added Split, join, round (and more??) to its vba arsenal.

Split takes a text string and splits it up based on a chosen character and
returns an array with each piece as a different element.


TH wrote:

Don't know what the split function is except to split windows.

One way is to use InStr and search for the comma to get it's position, then
use the LEFT function to extract that many characters - 1.

TH

On 4/16/04 8:38, in article , "PCC"
wrote:

I need to get the left portion of a variable length string
up to the comma delimiter. I tried the Split function but
apparently I'm not getting it right.
For Example:

Ex1:
The string: "Duck, Donald - 8765"
I want to get "Duck"

Ex2:
The String: "Mouse, Mickey - 3456"
I want to get "Mouse"


--

Dave Peterson

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Nees Function to Split ytayta555 Excel Worksheet Functions 3 February 25th 10 08:45 PM
Split Cell using If or other function JPS Excel Worksheet Functions 0 March 19th 09 03:50 PM
What are the main benifits of using the Split function? Krazy23848 Excel Worksheet Functions 3 August 15th 08 05:41 PM
Split Cells using a Function Morpheus2067 Excel Worksheet Functions 1 May 25th 06 05:31 PM
Split Function TAM Excel Programming 1 February 21st 04 10:23 AM


All times are GMT +1. The time now is 09:15 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"