我正在尝试调整多个工作表中的多个列。出于某种原因,只有第一个起作用。是因为我正在改变这两个变量吗?
Set targetSh = owb.Sheets("INPUT_INSTRUMENT")
Set resizeSh = owb.Sheets("Info")
tablename = "Table5"
Call RowsAction(targetSh, resizeSh, tablename)
Set resizeSh = owb.Sheets("Review")
tablename = "Table17"
Call RowsAction(targetSh, resizeSh, tablename)
Sub RowsAction(ByRef targetSh As Worksheet, resizeSh As Worksheet, tablename As String)
Dim i, iLastRow As Integer, oLastRow As ListRow, srcRow As Range
Last = targetSh.Range("A1", targetSh.Cells(Rows.count, "A").End(xlUp)).count - 2
For i = 1 To Last
Set srcRow = resizeSh.ListObjects(tablename).ListRows(i).Range
Set oLastRow = resizeSh.ListObjects(tablename).ListRows.Add
srcRow.Copy
oLastRow.Range.PasteSpecial
Application.CutCopyMode = False
Next
End Sub