2012-10-23 151 views
0
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 

如何僅將wsI的值複製到wsO?將工作表複製到工作表 - 如何僅複製值?

回答

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 
+0

您好保羅,謝謝您的幫助。 – w0rksh0p

相關問題