|
楼主 |
发表于 2022-9-23 11:27
|
显示全部楼层
大佬你好,我想法是把录入界面数据放入数组,然后用循环在数组里取值。
Sub 循环法录入到备份()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Dim arr, i&, k&, j&
Dim wb As Workbook, path$
With Sheets("录入")
arr = .Range("A1:D8")
End With
path = ThisWorkbook.path & "\备份.xlsx"
Set wb = Workbooks.Open(path)
endRow = Sheet1.Cells(Rows.Count, 1).End(xlUp).Row
Range("A" & Cells(Rows.Count, 1).End(xlUp).Row + 1) = Cells(Rows.Count, 1).End(xlUp).Row
j = 2
For k = 2 To 4 Step 2
For i = 3 To 8
Range(Cells(Rows.Count, 1).End(xlUp).Row + 1, j) = arr(i, k)
j = j + 1
Next
Next
wb.Close True
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
这种想法可行不?
还有就是Range里面的参数都是变量时候如何表达?
谢谢大佬!
|
|