将工作表复制到工作表 - 如何仅复制值?

时间:2012-10-23 13:47:47

标签: worksheet

Sub Sample()

Dim wsI As Worksheet, wsO As Worksheet, ws2 As Worksheet
Dim LastRow As Long, i As Long, j As Long

Set wsI = Sheets("EC6")
Set wsO = Sheets("2")

 LastRow = wsI.Range("A" & Rows.Count).End(xlUp).Row

j = 1

With wsI
    For i = 1 To LastRow
        wsI.Rows(i).Copy wsO.Rows(j)

        j = j + 1
    Next i
End With
End Sub

如何仅将VALI从wsI复制到wsO?

1 个答案:

答案 0 :(得分:0)

如果您的目标工作表已经存在(即您有31个工作表,名为1到31):

Dim wsI As Worksheet, wsO As Worksheet, ws2 As Worksheet
Dim LastRow As Long, i As Long, j As Long

Set wsI = Sheets("EC6")

Set wsO = Sheets(wsI.Cells(49, 1).Value)

LastRow = wsI.Range("A" & Rows.Count).End(xlUp).Row

j = 1

With wsI
    For i = 1 To LastRow
        wsI.Rows(i).Copy wsO.Rows(j)

        j = j + 1
    Next i
End With