Copy and Paste Specific Cells from one worksheet to another

前端 未结 2 1779
南笙
南笙 2021-01-28 23:05

I have a spreadsheet Sheet1 I have a row with some cell values as shown in Image 1. I am having a problem trying to copy and paste cells from one worksheet to another in excel.

2条回答
  •  一个人的身影
    2021-01-28 23:48

    Try this script.

    Sub CopyData1()
    Dim cell As Range, rw As Long
    rw = 2
    For Each cell In ActiveSheet.Range("A1:H20")
    If Not IsEmpty(cell) = True Then
    Worksheets("Sheet2").Cells(rw, 1).Value = cell.Value
    rw = rw + 1
    End If
    Next
    End Sub
    

    I'm assuming you have a sheet named 'Sheet2'. If not, just rename the sheet where you want the values copied to.

提交回复
热议问题