簡體   English   中英

如何在跳過空白單元格的同時將一張工作表中的一列復制到另一張工作表中的另一列?

[英]How do you copy one column in one sheet to another column in a different sheet, while skipping over blank cells?

我有一張紙,其中有一列從 C2 到 C6115。 在該范圍內有許多空單元格。 我只想在 excel 2007 中使用 VB 將填充的單元格復制到單獨的工作表中。誰能給我一個通用代碼來幫助我執行此操作?

Sub copy()
Dim i As Long
Dim cell As Range
i = 1
For Each cell In Sheets(1).Range("c2:c6115")
    If Not IsEmpty(cell) Then
        Sheets(2).Range("c" & i).Value = cell.Value
        i = i + 1
    End If
Next cell
End Sub

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM