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
 

Some videos you may like

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

Tom Urtis

MrExcel MVP
Joined
Feb 10, 2002
Messages
11,222
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)
 

acw

MrExcel MVP
Joined
Feb 13, 2004
Messages
4,814
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
 

Phil-e

Board Regular
Joined
Jun 28, 2004
Messages
65
Thanks Tom & ACE, that was quick. Just what I needed. Somtimes you can't see the forest for the trees.
Phil
 

Watch MrExcel Video

Forum statistics

Threads
1,118,167
Messages
5,570,635
Members
412,334
Latest member
ExcelForLifeDontHate
Top