跳到主要內容

在 Excel 中切換名字和姓氏:簡單完整的指南

在許多情況下,姓名通常以“名姓”格式列出。然而,在某些情況下,最好將此順序顛倒為“姓氏,名字”,將姓氏放在前面,然後是逗號,最後是名字。無論是出於組織、資料庫管理還是風格原因,翻轉名稱的排列可能是必要的,但如果在大型資料集中手動完成,可能會很乏味。

本教學向您展示如何在 Excel 中輕鬆地重新排列姓名,無論您是將姓名從「名字姓氏」翻轉為「姓氏,名字」(有或沒有逗號)還是相反。無論您需要簡單的交換還是涉及高級功能或腳本的更複雜的解決方案,我們都能滿足您所需的一切。


使用快速填充翻轉名字和姓氏

Excel的 Flash填充 功能是一種智慧且高效的工具,可根據您提供的模式自動填入資料。這使得它非常適合顛倒資料集中名字和姓氏的順序等任務。請按照以下簡單步驟使用「快速填充」來翻轉姓名:

  1. 在您姓名旁邊的空列的第一個儲存格中(例如, B2),輸入儲存格中的名稱 A2 以相反的順序:“姓,名".
  2. 選取同一列中的下一個儲存格,然後輸入儲存格中的反向名稱 A3. 當您開始輸入時,快速填充功能將識別該模式並根據該模式自動填入剩餘的儲存格。
  3. 媒體推薦 Enter 確認快速填充建議。

    小提示: 作為步驟 2 和 3 的替代方法,您可以按 按Ctrl + E 在鍵盤上,或前往 數據 功能區上的選項卡,然後按一下 Flash填充 按鈕以您提供的模式填滿下面的儲存格 B2.

筆記:

  • 如果您不想包含逗號或希望將順序從“姓氏、名字”恢復為“名字姓氏”,則此方法同樣有效。關鍵是提供您希望看到的複製的初始模式。

  • 如果有些姓名有中間名,有些則沒有,快速填充可能無法無縫處理它們。為了在這些情況下獲得更好的結果,請參閱 人工智慧方法 在下一節中描述。
  • Flash Fill提供了固定的解決方案;透過此方法反轉的名稱保持靜態,這表示它們不會隨著原始名稱的變更或新條目的新增而動態更新。對於自動更新的動態解決方案, 公式法 被推薦。

使用 AI 切換名字和姓氏

Excel的Kutools 配備人工智慧助手, 人工智慧助手,旨在輕鬆顛倒名稱順序,無論它們是否包含中間名。利用使用者友善的介面 Kutools 人工智慧助手,您可以根據需要輕鬆顛倒單一或多個選定範圍中的名稱順序。請依照以下步驟操作:

注意: 使用AI操作後,撤銷功能將無法使用。建議在進行任何人工智慧輔助修改之前建立原始資料的備份。

下載 Excel的Kutools 存取該功能並解鎖 30 天免費試用!
  1. 導航到 庫工具 Excel 功能區上的標籤並選擇 人工智慧助手 打開 Kutools 人工智慧助手 接口。
  2. 選擇要翻轉的名稱。
  3. 在輸入框中清楚地鍵入您的命令。例如,您可以輸入:“將所選內容中的姓氏移到前面,後面跟著逗號".
  4. 媒體推薦 Enter 或打 送出 按鍵 .

  5. Kutools 人工智慧助手 及時處理您的命令,提出解決方案。只需單擊 執行 按鈕以對所選資料套用重新排列。

結果

所選儲存格中的所有姓氏均移至前面,後面跟著逗號。

如果結果不符合您的期望,提示:
  1. 只需點擊即可 不滿意 按鈕。 Kutools 人工智慧助手 然後將撤消相反的操作並產生適合您需求的詳細逐步指南。

  2. 考慮重新表達您的命令,看看它是否會產生更令人滿意的結果。

注意: 想要訪問 Kutools 人工智慧助手? 下載 Excel的Kutools 現在! 除此之外,Kutools 還擁有 300 多個其他功能,並提供 30 天免費試用。 不要等待,今天就來試試吧!


使用公式反轉名字和姓氏

若要使用公式反轉 Excel 中的名字和姓氏,您可以依靠 Excel 的文字操作功能。當您需要一個在原始名稱變更時自動更新的動態解決方案時,此方法特別有用。請依照以下步驟實施該公式:

  1. 假設您要反轉的名稱位於列中 A, 從...開始 A2。選擇要顯示反轉名稱的列中的第一個儲存格 (B2 在我們的例子中),然後輸入公式:
    =REPLACE(A2,1,SEARCH(" ",A2),"")&", "&LEFT(A2,SEARCH(" ",A2)-1)
    小提示: 在提供的公式中,確保替換 A1 與包含您想要反轉的名稱的實際儲存格參考。
  2. 拖曳單元格右下角的填充柄 B2 向下將公式套用至所有相關儲存格。

提示:
  • 如果您不想包含逗號而只包含空格,請考慮使用以下公式:
    =MID(A2&" "&A2,FIND(" ",A2)+1,LEN(A2))

  • 如果您希望將順序從“姓氏、名字”恢復為“名字姓氏”,請使用下列公式:
    =MID(A2&" "&A2,FIND(", ",A2)+2,LEN(A2)-1)

(AD)使用 Kutools for Excel 輕鬆反轉文字順序

是否正在努力反轉 Excel 單元格中的文本,無論是單獨翻轉每個字母還是圍繞特定分隔符號重新排列文本? Kutools for Excel 讓一切變得簡單!

隨著 反向文字順序 功能,您可以快速反轉單元格內的字母或反轉由您選擇的分隔符號分隔的文本段 - 所有這些都通過一個簡單的對話框完成!

Excel的Kutools:整合AI🤖,300+便利的Excel功能觸手可及。 現在就開始 30 天免費試用,沒有任何功能限制!


使用交換名字和姓氏 Power Query

運用 Power Query in Excel 是一種用於操作和轉換資料的強大方法,包括在插入您選擇的分隔符號時交換名字和姓氏的位置。請依照以下詳細步驟完成此任務 Power Query:

注意: 選擇 Power Query 方法 專門針對特定場景:如果 Power Query 已經是資料轉換工作流程的一部分,您需要整合名稱反轉,或者如果您經常面臨類似的任務。對於一次性名稱反轉的需求,可以使用更簡單的替代方案,例如 Flash填充, AI, 或者 公式 (如本指南前面所述)可能是更合適和直接的解決方案。

  1. 選擇包含要反轉的名稱的範圍。
  2. 導航到 數據 標籤並點擊 從表/範圍 ,在 獲取和轉換數據 組。
  3. 如果您的資料不是表格格式,Excel 會提示您建立表格。請點選 OK.

  4. Power Query 編輯頁 打開後,右鍵單擊名稱列的標題,然後選擇 拆分列 > 按分隔符.

  5. 選擇分隔符 分隔您的姓名(通常是空格)並選擇 在每次分隔符號時進行分割,然後單擊 OK.

  6. 拆分後,您將有兩列用於顯示名字和姓氏。手動將保留姓氏的列拖曳到第一列。

  7. 按住選擇要合併的列 按Ctrl 鍵並單擊每一個。然後,右鍵單擊任意列標題並選擇 合併列.

  8. 合併列 對話框,從 分離器 下拉列表中,選擇 習俗 選項並輸入逗號,後面接著一個空格 (, ) 為分隔符號。如果需要的話, 指定一個名稱 對於合併列,然後按一下 OK.

  9. 對預覽滿意後,點擊 關閉並加載 按鈕在 Power Query 編輯頁 應用您的更改。

結果

Power Query 將立即將轉換後的資料輸出到 Excel 中的新工作表中。

小提示: 此方法在原始資料和轉換後的輸出之間建立連結。對原始資料的任何更新都可以透過刷新輕鬆應用於轉換後的輸出:只需右鍵單擊輸出表並選擇 刷新.


使用 VBA 交換名字和姓氏

您也可以使用 VBA 巨集快速翻轉列中的名字和姓氏。對於喜歡使用編碼方法在 Excel 中高效操作資料的任何人來說,此方法是理想的選擇。

注意: 在執行此 VBA 腳本之前,強烈建議建立資料備份,因為無法使用標準 Excel 撤銷功能撤銷 VBA 作業。

  1. 按住 Alt + F11鍵 在Excel中打開鍵 Microsoft Visual Basic for Applications 窗口。
  2. 點擊 插入 > 模塊,並將以下巨集貼到 模塊 窗口。
    Sub FlipName()
    'Update by ExtendOffice on 20240327
    Dim xRng As Range
    Dim xWorkRng As Range
    Dim xSign As String
    Dim xSeparator As String
    On Error Resume Next
    xTitleId = "Kutools for Excel"
    Set xWorkRng = Application.Selection
    Set xWorkRng = Application.InputBox("Flip names in the range:", xTitleId, xWorkRng.Address, Type:=8)
    xSign = Application.InputBox("Input the separator used within names:", xTitleId, Type:=2)
    For Each xRng In xWorkRng
        xValue = xRng.Value
        NameList = VBA.Split(xValue, xSign)
        If UBound(NameList) = 1 Then
            xRng.Value = NameList(1) & ", " & NameList(0)
        End If
    Next
    End Sub

    注意: 該巨集會自動在顛倒的名稱之間插入逗號。如果您想使用不同的分隔符,您可以修改程式碼片段 xRng.Value = NameList(1) & ", " & NameList(0) 在程式碼的第16行找到。例如,替換 “” with “” 將用空格而不是逗號分隔名稱。

  3. F5 運行此宏的鍵。 在彈出 Excel的Kutools 在對話方塊中,選擇包含要翻轉的名稱的範圍,然後按一下 OK 按鈕。

  4. 在下一個對話方塊中,請輸入名稱中使用的現有分隔符號(例如我們範例中的空格),然後按一下 OK 按鈕。

結果

現在,所選範圍內的名字和姓氏將被翻轉,並以逗號分隔。


以上就是Excel中翻轉姓名相關的全部內容。我希望本教程對您有所幫助。如果您想探索更多 Excel 提示和技巧, 請點擊這裡 訪問我們廣泛收集的超過數千個教程。

Comments (42)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
It worked for me.
Thank you!
This comment was minimized by the moderator on the site
hola, gracias por tus formulas, como puedo hacer si necesito reversar los nombres y luego los apellidos, por ejemplo tengo esto GRANDA VELASCO OMAR GERMANICO, y con la función revert no me funciona en orden me saca GERMANICO OMAR VELASCO GRANDA, me cambia el orden.
This comment was minimized by the moderator on the site
Hi there,

If you have additional middle names rather than just first and last names, please try the Reverse Text Order feature of Kutools for Excel.
https://www.extendoffice.com/images/stories/comments/ljy-picture/reverse-text.png

If you don't have Kutools for Excel installed in your computer, you can click here to download and try it for free for 30 days: Kutools for Excel. After the installation, you can find the feature on Kutools tab, in Editing group:
https://www.extendoffice.com/images/stories/comments/ljy-picture/reverse-text-2.png

Amanda
This comment was minimized by the moderator on the site
Thank you sooo very much! You made work easier for me!
This comment was minimized by the moderator on the site
=MID(A2&", "&A2,FIND(" ",A2)+1,LEN(A2)+1)

where the name is on the A2 cell
This comment was minimized by the moderator on the site
You saved my life!!! Thank you. None of the others worked. This is exactly what I needed.
This comment was minimized by the moderator on the site
=MID(O4&", "&O4,FIND(" ",O4)+1,LEN(O4)+1)
This comment was minimized by the moderator on the site
okay. can someone say this in english because I have no clue what you guys are talking about
This comment was minimized by the moderator on the site
Try this to add a comma: =MID(A2&", "&A2,FIND(" ",A2)+1,LEN(A2)+1)
This comment was minimized by the moderator on the site
THANK YOU literally I've been trying to figure out the comma thing for like an hour. Thank you!
This comment was minimized by the moderator on the site
What if I need to insert a comma between the last and first name?
This comment was minimized by the moderator on the site
What if there is a comma separating the 2 names? Is there a way to eliminate it? Now the names look like

Arthur Lange,

Eric Norris,

etc etc
This comment was minimized by the moderator on the site
Try this to remove a comma: =MID(A2&" "&A2,FIND(", ",A2)+1,LEN(A2)+1)
This comment was minimized by the moderator on the site
Have you tried Ctrl+F, Select Replace, Find "," and leave replace with blank.
This comment was minimized by the moderator on the site
When I try that, it pops up with this error message "There's a problem with this formula. Not trying to type a formula? When the first character is an equal (=) or minus (-) sign, Excel thinks it's a formula: you type: =1+1, cell shows: 2. To get around this, type an apostrophe (') first: you type: '=1+1, cell shows =1+1.
This comment was minimized by the moderator on the site
I think you are changing the formula. Try copying and pasting the values to a new cell then do the find/replace.
This comment was minimized by the moderator on the site
I want to know this too!
This comment was minimized by the moderator on the site
Correction. What if i have four names? What's the formula? Last name - first name - middle1 - middle2
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations