我尝试创建一个循环,从Workbook1.Worksheet1的M列中获取数据,从第9行开始到第700行,然后将其粘贴到Workbook2.Worksheet2的F8单元格中。之后,它将从Workbook1中获取下一行(第N列),并将其粘贴到Workbook2 8列后(第N8单元格)。它重复24次以获取Workbook1中的所有行。
Sub importdata()
Dim J As Integer
Dim K As Integer
J = 6
K = 13
Wrksht1 As Range
Wrksht2 As Range
Set wb1 = Workbooks("Workbook1.xlsm")
Set wb2 = Workbooks("Workbook2.xlsb")
Set ws1 = wb1.Sheets("Worksheet1")
Set ws2 = wb2.Sheets("Worksheet2")
For I = 1 To 24
Set Wrksht2 = ws2.Range(K & 9)
Set Wrksht1 = ws1.Range(J & 8)
Wrksht1 = Wrksht2
J = J + 8
K = K + 1
Next I
End Sub
这是我现在的代码,我让循环工作,所以它应该把值放在workbook2的正确位置,但我不能让循环从workbook1的行中抓取值并将值粘贴到定向位置。
1条答案
按热度按时间b91juud31#
尝试