ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   first name and a second name - In Sheet2 I only need the first name (https://www.excelbanter.com/excel-programming/278063-first-name-second-name-sheet2-i-only-need-first-name.html)

tegger

first name and a second name - In Sheet2 I only need the first name
 
Sheet1 Range A2 contains a first name and a second name.

Sheet2 Range A2 contains =(Sheet1!A2)

In Sheet2 I only need the first name.

Can I do this with a formula?



Thanks,

DL



Bill Barclift

first name and a second name - In Sheet2 I only need the first name
 
Take a look at the Mid/Instr functions or Split function. In either case,
the first name/last name must have a delimitter to distinguish them (space,
comma, etc.). Both of the following cases assume comma delimitted.

Using Mid/Instr functions:

Mid(rng.Value, 1, InStr(sFullName, " ") - 1)

Using Split function (1st array member contains first name, 2nd array member
contains last name):

aryTemp = Split(sFullName)


Bill Barclift

"tegger" wrote in message
...
Sheet1 Range A2 contains a first name and a second name.

Sheet2 Range A2 contains =(Sheet1!A2)

In Sheet2 I only need the first name.

Can I do this with a formula?



Thanks,

DL





Trevor Shuttleworth

first name and a second name - In Sheet2 I only need the first name
 
=IF(ISERROR(FIND(" ",Sheet1!A2)),Sheet1!A2,LEFT(Sheet1!A2,FIND("
",Sheet1!A2)-1))

Regards

Trevor


"tegger" wrote in message
...
Sheet1 Range A2 contains a first name and a second name.

Sheet2 Range A2 contains =(Sheet1!A2)

In Sheet2 I only need the first name.

Can I do this with a formula?



Thanks,

DL






All times are GMT +1. The time now is 01:40 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com