Jump to content

Get Text left of , and right of ,


Recommended Posts

2 minutes ago, MacFileman said:

Need the copy to the left of the comma..and then the copy to the right. 

The following calculation will return the text before the first comma:

Left ( text ; Position ( text ; "," ; 1 ; 1 ) - 1 )

Note that this assumes the given text does contain a comma - otherwise the result will be empty.


To extract the text after the first comma, you can use:

Right ( text ; Length ( text ) - Position ( text ; "," ; 1 ; 1 ) )

Note that "text after the first comma" includes the space immediately following the comma; if you don't want that, subtract 1 from the calculated position.


Alternatively you could start by substituting the comma with a carriage return, then use the GetValue() function to retrieve one of the resulting values. This is often a convenient shortcut - but it's usefulness is limited to specific cases. If you want to be able to parse any text, I recommend getting familiar with the basic method using Left(), Right(), Middle(), Position() and Length() functions.

 

 

 

  • Like 1
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.