trimng text

Phil-e

Board Regular
Joined
Jun 28, 2004
Messages
65
Is there a way to trim text strings after a comma(,). To avoid a lot of typing I need to copy and past from one sheet to another. The problem is that in the cell on the "copy sheet" it has (lastname, firstname middleinitial.) I only want the (lastname) pasted in the new sheet/cell. I need to cut every thing past the comma. Any ideas? :confused: THANKS
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Maybe this will help, this formula will return whatever is in the cell to the left of the comma, A1 for example:

=LEFT(A1,FIND(",",A1)-1)
 
Upvote 0
Hi

Assuming the data is in A4 then

Left(Range("a4"), InStr(1, Range("a4"), ",") - 1)
will get all the data to the left of the comma. If you want to include the comma, then remove the -1.


Tony
 
Upvote 0
Thanks Tom & ACE, that was quick. Just what I needed. Somtimes you can't see the forest for the trees.
Phil
 
Upvote 0

Forum statistics

Threads
1,214,935
Messages
6,122,337
Members
449,077
Latest member
Jocksteriom

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top