跳到主要內容

如何在Excel中快速翻轉/反轉一行數據順序?

當您需要反轉或翻轉行的數據順序時,如何快速完成它? 通常,您可能必須使用VBA代碼或其他Excel加載項,因為Excel不支持此類操作。 隨之而來的以下棘手的事情將幫助您快速翻轉或反轉Excel中的數據順序。

使用VBA在行中水平翻轉/反轉數據順序

使用Kutools for Excel在行中水平翻轉/反轉數據順序



箭頭藍色右氣泡 使用VBA在行中水平翻轉/反轉數據順序

這是一個簡潔的VBA宏,可以幫助您快速翻轉/反轉水平行中的數據順序。

步驟 1:按住 其他 + F11 鍵,然後打開 Microsoft Visual Basic for Applications 窗口。

步驟 2:點擊 插入 > 模塊,然後將以下宏粘貼到 模塊窗口。

Sub FlipRows()
'Updateby20131126
Dim Rng As Range
Dim WorkRng As Range
Dim Arr As Variant
Dim i As Integer, j As Integer, k As Integer
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
Arr = WorkRng.Formula
For i = 1 To UBound(Arr, 1)
    k = UBound(Arr, 2)
    For j = 1 To UBound(Arr, 2) / 2
        xTemp = Arr(i, j)
        Arr(i, j) = Arr(i, k)
        Arr(i, k) = xTemp
        k = k - 1
    Next
Next
WorkRng.Formula = Arr
End Sub

步驟 3: 按 F5 鍵運行該宏,並顯示一個對話框供您選擇要使用的範圍,請參見屏幕截圖:

文檔逆序8

第一步: 媒體推薦 OK,您可以看到如下所示的結果:


箭頭藍色右氣泡 使用Kutools for Excel在行中水平翻轉/反轉數據順序

這款獨特的敏感免洗唇膜採用 Moisture WrapTM 技術和 Berry Mix ComplexTM 成分, Excel的Kutools翻轉水平範圍 工具,您可以在選定的行中快速水平翻轉/反轉數據順序。

Kutools for Excel包括300多個便捷的Excel工具。 30天免費試用,不受限制。 立即獲取.

步驟 1:選擇要在其中翻轉數據的行。

步驟 2: 點擊 庫工具 > 範圍轉換器 > 翻轉水平範圍,請參見屏幕截圖:

文檔反向行順序3

然後,您將看到在所選行中所有數據順序都顛倒了。

文檔反向行順序4
-1
文檔反向行順序5

點擊 翻轉水平範圍 進一步了解此功能。


相關文章:

如何在Excel中垂直翻轉/反轉一列數據順序?

最佳辦公生產力工具

🤖 Kutools 人工智慧助手:基於以下內容徹底改變數據分析: 智慧執行   |  生成代碼  |  建立自訂公式  |  分析數據並產生圖表  |  呼叫 Kutools 函數...
熱門特色: 尋找、突出顯示或識別重複項   |  刪除空白行   |  合併列或儲存格而不遺失數據   |   沒有公式的回合 ...
超級查詢: 多條件VLookup    多值VLookup  |   跨多個工作表的 VLookup   |   模糊查詢 ....
高級下拉列表: 快速建立下拉列表   |  依賴下拉列表   |  多選下拉列表 ....
欄目經理: 新增特定數量的列  |  移動列  |  切換隱藏列的可見性狀態  |  比較範圍和列 ...
特色功能: 網格焦點   |  設計圖   |   大方程式酒吧    工作簿和工作表管理器   |  資源庫 (自動文字)   |  日期選擇器   |  合併工作表   |  加密/解密單元格    按清單發送電子郵件   |  超級濾鏡   |   特殊過濾器 (過濾粗體/斜體/刪除線...)...
前 15 個工具集12 文本 工具 (添加文本, 刪除字符,...)   |   50+ 圖表 類型 (甘特圖,...)   |   40+ 實用 公式 (根據生日計算年齡,...)   |   19 插入 工具 (插入二維碼, 從路徑插入圖片,...)   |   12 轉化 工具 (數字到單詞, 貨幣兌換,...)   |   7 合併與拆分 工具 (高級合併行, 分裂細胞,...)   |   ... 和更多

使用 Kutools for Excel 增強您的 Excel 技能,體驗前所未有的效率。 Kutools for Excel 提供了 300 多種進階功能來提高生產力並節省時間。  點擊此處獲取您最需要的功能...

產品描述


Office選項卡為Office帶來了選項卡式界面,使您的工作更加輕鬆

  • 在Word,Excel,PowerPoint中啟用選項卡式編輯和閱讀,發布者,Access,Visio和Project。
  • 在同一窗口的新選項卡中而不是在新窗口中打開並創建多個文檔。
  • 將您的工作效率提高 50%,每天為您減少數百次鼠標點擊!
Comments (7)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
In response to Rodrigo, Fbkil:

The error occurs because when you cut and paste the macro text into the Excel VBA editor, there are non-printing characters hidden in the area where the macro rows are indented. Delete them and it will work.

Note: Solved by someone else, not me. Was tricky, as it looked like it should work, but didn't.
This comment was minimized by the moderator on the site
When I try to run this macro, I get the message "syntax error" with the command line "For j = 1 To UBound(Arr, 2) / 2" highlighted in red. Does anyone know how to fix it?
This comment was minimized by the moderator on the site
got the same error. update needed
This comment was minimized by the moderator on the site
Great tool, thanks so much for VBA - I transposed a column to rows first and then used your VBA for reversing - saved tons of time!
This comment was minimized by the moderator on the site
You flipped the column order not the row order as per the title.
This comment was minimized by the moderator on the site
Copy paste (transpose) the row to column. Add 1 to x on the column beside. Filter from largest to smallest and expand. Then copy paste result and transpose to row again
This comment was minimized by the moderator on the site
A quicker way would be be to copy your selection. Right click, choose paste special. Check the transpose button, hit ok and the rows and columns will be transposed. http://office.microsoft.com/en-us/excel-help/switch-transpose-columns-and-rows-HP010224502.aspx
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations