ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Make a column two columns (https://www.excelbanter.com/excel-programming/297477-make-column-two-columns.html)

tod

Make a column two columns
 
The easiest way is to use Text to Columns. Highlight the
names. Choose Data from the menu bar, then Text to
Columns. Choose the Delimited radio button and then Next.
If the name is "Last, First", check the Comma box. If it
is "First Last", choose the Space box. Then Next and
Finish.

VBA-wise, you could use code like this:

If the format is "Last, First"
Sub Sample()
For Each Cell in ActiveSheet.Range("A2:A" &
ActiveSheet.Range("A65536").End(xlup).Row)
Cell.Offset(0,1).Value = Left(Cell,Application.Find
(",", Cell)-1)
Cell.Offset(0,2).Value = Mid(Cell,Application.Find
(", ", Cell)+2)
Next Cell
End Sub

If the format is "First Last"
Sub Sample()
For Each Cell in ActiveSheet.Range("A2:A" &
ActiveSheet.Range("A65536").End(xlup).Row)
Cell.Offset(0,1).Value = Left(Cell,Application.Find
(" ", Cell)-1)
Cell.Offset(0,2).Value = Mid(Cell,Application.Find
(" ", Cell)+1)
Next Cell
End Sub

tod


-----Original Message-----
You can merge first name and last name to make a full

name column, but is there a way to take a full name column
and make it two separate columns, first and last?
.



All times are GMT +1. The time now is 08:50 AM.

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