在Excel中,我有名字的列的格式为“姓”。我想将整列分成两列,一列包含所有的名字,另一列包含所有的姓氏。如何将列中的数据拆分为两个单独的列?
到目前为止我的代码:
'Splitting the Traveler Display Name column
Dim SplitPoint As Long
'L2 is the column containing names to be split
Range("L2").Select
Do Until IsEmpty(ActiveCell)
'Search for position of space within the cell
SplitPoint = InStrRev(ActiveCell, " ", -1, vbTextCompare)
'Put the last name in the column next to the source column
ActiveCell.Offset(0, 1) = Trim(Left(ActiveCell, SplitPoint))
'Replace the source column with the first name
ActiveCell.Offset(0, 0) = Trim(Mid(ActiveCell, SplitPoint))
Loop
这是不合理的,我处理的数据量,我发现迄今已要求该细胞可手动选择的解决方案。我发现这个解决办法,但我得到以下错误:无效的过程调用或参数。
我格式化从SharePoint,这需要大量的时间,如果我必须手动格式化每个柱因为我到片材以其他方式格式化,以及导出的数据。到目前为止,我一直在使用文本到列,但是你发布的VBA方法是我正在寻找的。谢谢。 – Hunterhod