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

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
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,216,536
Messages
6,131,227
Members
449,637
Latest member
icecreampie

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