View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Frank Kabel Frank Kabel is offline
external usenet poster
 
Posts: 3,885
Default How to separate First name and Last Name

Hi
one way:

sub foo()
Dim firstName as string
Dim lastName as string
Dim rng as range
set rng = activesheet.range("D3")
with rng
firstname=left(.value,instr(.value," ")-1)
lastname=mid(.value,instr(.value," ")+1,255)
end with
end sub

--
Regards
Frank Kabel
Frankfurt, Germany

Suppose in cell D3, the value is "Christine White".

I have two variables, firstName and lastName as String.

How can I separate "Christine White", so that firstName = "Christine"
and lastName = "White"??

Thx a lot!


---
Message posted from http://www.ExcelForum.com/