Excel には、"FirstName LastName" という形式の名前の列があります。その列全体を 2 つの列に分割し、1 つはすべての名前を含み、もう 1 つはすべての姓を含みます。
これまでの私のコード:
'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
これまでに見つけた解決策では、セルを手動で選択する必要がありましたが、これは私が扱っているデータの量には不合理でした。この解決策を見つけましたが、次のエラーが表示されます: Invalid Procedure call or argument。