跳到主要內容

如何在Excel中僅複製和粘貼非空白單元格?

我們大多數人都可能會遇到此問題,當我們複製包含一些空白單元格的數據列表,然後將它們粘貼到另一列時,空白單元格也會被粘貼。 當我們不需要空白並且只希望粘貼非空白單元格時,這非常煩人。 在這種情況下,我們如何才能快速便捷地僅複製和粘貼Excel中的非空白單元格? 以下是一些解決您的快速技巧:

使用轉到特殊命令僅複製和粘貼非空白單元格

使用過濾器功能僅複製和粘貼非空白單元格

使用數組公式僅複製和粘貼非空白單元格

僅複製和粘貼帶有VBA代碼的非空白單元格

使用Kutools for Excel僅複製和粘貼非空白單元格 好主意3


箭頭藍色右氣泡 使用轉到特殊命令僅複製和粘貼非空白單元格

隨著 去特別 命令,您可以先選擇所有數據,然後將其複制並粘貼到其他位置。

1。 選擇您要使用的數據列表。

僅文檔複製非空白1

2。 然後點擊 首頁 > 查找和選擇 > 去特別,請參見屏幕截圖:

僅文檔複製非空白1

3。 在 去特別 對話框,檢查 常量 選項,請參見屏幕截圖:

僅文檔複製非空白1

4。 然後點擊 OK,並且僅在列表中選擇了值單元格。

僅文檔複製非空白1

5。 然後將數據複製並粘貼到所需的位置。 並且僅粘貼了非空白單元格值。 看截圖:

僅文檔複製非空白1

備註:此方法僅適用於常量,不適用於公式單元格。


箭頭藍色右氣泡 使用過濾器功能僅複製和粘貼非空白單元格

篩選 功能可以幫助您首先過濾非空白單元格,然後可以根據需要將其複制並粘貼到其他單元格中。

2。 點擊 數據 > 篩選,請參見屏幕截圖:

doc僅複製nonblanks6

3。 然後點擊所選列表中單元格右上角的下拉按鈕,然後取消選中 空白 下拉菜單下的選項。 看截圖:
僅文檔複製非空白1

4。 然後點擊 OK,所有非空白的單元格都已被過濾掉,如下圖所示:

僅文檔複製非空白1

5。 最後,您可以復製過濾的數據並將其粘貼到所需的任何位置。

備註:值和公式都通過這種方式生效。


一次選擇非空白單元格

點擊即可獲得 30 天的免費全功能試用!
doc kutools選擇非空白單元格

箭頭藍色右氣泡 使用數組公式僅複製和粘貼非空白單元格

要僅複製和粘貼非空白單元格,您還可以應用以下數組公式。

1。 除了數據之外,在空白單元格中輸入以下公式:

=LOOKUP("zzzzz",CHOOSE({1,2},"",INDEX(A:A,SMALL(IF($A$1:$A$15<>"",ROW($A$1:$A$15)),ROWS($B$1:B1)))))

僅文檔複製非空白1

備註:在以上公式中, A1:A15 是您要使用的數據列表。您可以根據需要進行更改。

2。 然後按 Shift + Ctrl + 輸入 鍵,然後選擇單元格B1,並將填充手柄拖到您要包含此公式的範圍內,並且所有非空白單元格值都已提取。 看截圖:

僅文檔複製非空白1

3。 由於它們是公式,因此將它們複製到其他位置時,應該將它們複製並粘貼為值。

備註:此公式僅適用於常數,不適用於公式單元格。


箭頭藍色右氣泡 僅複製和粘貼帶有VBA代碼的非空白單元格

如果您對VBA代碼感興趣,則可以執行以下代碼來完成此任務。

1。 按住 ALT + F11 鍵,然後打開 Microsoft Visual Basic for Applications窗口.

2。 點擊 插入 > 模塊,然後將以下代碼粘貼到 模塊窗口.

VBA代碼:在Excel中僅複製和粘貼非空白單元格

Sub PasteNotBlanks()
'Update 20140325
Dim rng As Range
Dim InputRng As Range, OutRng As Range
xTitleId = "KutoolsforExcel"
Set InputRng = Application.Selection
Set InputRng = Application.InputBox("Range :", xTitleId, InputRng.Address, Type:=8)
If InputRng.Columns.Count > 1 Then
    MsgBox "Please select one column."
    Exit Sub
End If
Set OutRng = Application.InputBox("Out put to (single cell):", xTitleId, Type:=8)
InputRng.SpecialCells(xlCellTypeConstants).Copy Destination:=OutRng.Range("A1")
End Sub

3。 然後按 F5 鍵以運行此代碼,將出現一個提示框,提醒您選擇要使用的數據范圍。 看截圖:

僅文檔複製非空白1

4。 然後點擊 OK,則會彈出另一個提示框,讓您選擇一個單元格來放置數據。

僅文檔複製非空白1

5. 點擊 OK 完成此代碼,並且只有非空白單元格值已粘貼到您指定的位置。

備註:此代碼僅可用於常量。


箭頭藍色右氣泡 使用Kutools for Excel僅複製和粘貼非空白單元格

有沒有比以上更簡單的方法? 當然, Excel的Kutools's 選擇非空白單元格s實用程序可以幫助您首先選擇非空白單元格,然後復制並粘貼它們。

Excel的Kutools, 與以上 300 方便的功能,使您的工作更加輕鬆。 

免費安裝 Kutools for Excel,請執行以下操作:

1.選擇單元格範圍,然後單擊 庫工具 > 選擇 > 選擇非空白單元格。 看截圖:
doc選擇非空白單元格2

2.然後選擇非空白單元格,按 按Ctrl + C 複製它們,然後選擇要輸出粘貼結果的單元格,按 按Ctrl + V 粘貼選定的非空白單元格。 看截圖:
doc選擇非空白單元格3

箭頭藍色右氣泡 僅複製和粘貼非空白單元格

Kutools for Excel:Excel 中必須具備的 300 多個函數, 從這裡免費試用30天

最佳辦公生產力工具

🤖 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 (11)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
=Filter(A:A,A:A<>"")
This comment was minimized by the moderator on the site
Array formula Works fine on text
but don't work on numbers.
This comment was minimized by the moderator on the site
Not working on Numbers !!!
Works fine on text !!!
Please guide
This comment was minimized by the moderator on the site
Thanks for the great tips! I am using the Find & Select feature, but it's taking a long time because my spreadsheet contains 70 columns and 450k rows. Is there a way to fasten the process?
This comment was minimized by the moderator on the site
When i select and copy only non-blank cells, how can i then paste it somewhere else with keeping the same empty ranges between them?
This comment was minimized by the moderator on the site
These tools delete the blank cells and compress the row. I want the format to be retained, including the spaces, but I do not want empty cells to overwrite cells containing existing data. i.e. I want to add the new, copied, cells in a column onto an existing column.
This comment was minimized by the moderator on the site
Hi #abc I have used your formula =LOOKUP("zzzzz",CHOOSE({1,2},"",INDEX('List of Overdue items'!A:A,SMAL L(IF('List of Overdue items'!A$1:A$15 00"",ROW('List of Overdue items'!A$1:A$15 00)),ROWS('List of Overdue items'!B$1:B2)) ))) I have data in one Worksheet and want to copy that data into another worksheet (same doc). Can you help?
This comment was minimized by the moderator on the site
Is there a way to make the macro work when referencing between different sheets?
This comment was minimized by the moderator on the site
This formula is absolutely amazing, thank you. Unfortunately it breaks when trying to copy from another sheet, is there a workaround?
This comment was minimized by the moderator on the site
correct the references when using the formula between different sheets. It does work. =LOOKUP("zzzzz",CHOOSE({1,2},"",INDEX('List of Overdue items'!A:A,SMALL(IF('List of Overdue items'!A$1:A$1500"",ROW('List of Overdue items'!A$1:A$1500)),ROWS('List of Overdue items'!B$1:B2)))))
This comment was minimized by the moderator on the site
thanks for the super formula: =LOOKUP("zzzzz",CHOOSE({1,2},"",INDEX(A:A,SMALL(IF($A$1:$A$15"",ROW($A$1:$A$15)),ROWS($B$1:B1)))))
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations