开发者

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

开发者 https://www.devze.com 2023-03-10 02:45 出处:网络
I have a one sheet with a column which ranges from C2 till C6开发者_开发问答115. In that range there are many empty cells. I want to copy the filled cells only into a seperate sheet using VB in excel

I have a one sheet with a column which ranges from C2 till C6开发者_开发问答115. In that range there are many empty cells. I want to copy the filled cells only into a seperate sheet using VB in excel 2007. Can anyone give me a general code that can help me perform that?


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
0

精彩评论

暂无评论...
验证码 换一张
取 消