Name Macro

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have a column that has the first and last name separated by a space in
that column. Is there a way to write a macro to place the last name in a
different column?

Thanks!!

-Matt
 
You don't need a macro

=MID(A1,FIND(" ",A1)+1,99)

in B1 will get the surname, and copy down.

If you must have a macro

For Each cell In Selection
cell.Offset(0,1).Value = mid(Range("A1"),Instr(Range("A1")," ")+1, _
len(Range("A1"))-Instr(Range("A1"),"
"))
Next cell

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
Thanks, that did the trick!!



Bob Phillips said:
You don't need a macro

=MID(A1,FIND(" ",A1)+1,99)

in B1 will get the surname, and copy down.

If you must have a macro

For Each cell In Selection
cell.Offset(0,1).Value = mid(Range("A1"),Instr(Range("A1")," ")+1, _
len(Range("A1"))-Instr(Range("A1"),"
"))
Next cell

--

HTH

RP
(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top