我在IRow = ...
行上一直收到“类型不匹配”错误13我想知道如何修复此代码?
我也是
最好的问候。
Sub MoveColumns()
Dim iRow As Long
Dim iCol As Long
Dim data_sheet1 As Worksheet
Dim target_Sheet As Worksheet
Worksheets.Add.Name = "Final Report"
Set data_sheet1 = ActiveWorkbook.Worksheets("InputPrep")
Set target_Sheet = ActiveWorkbook.Worksheets("Final Report")
iRow = Sheets(data_sheet1).UsedRange.Rows.Count
'Determine how many rows are in use
答案 0 :(得分:0)
更改
iRow = Sheets(data_sheet1).UsedRange.Rows.Count
到
iRow = data_sheet1.UsedRange.Rows.Count
Sheets(index)
期望index
是工作表名称或索引编号。但是您传递的是Worksheet类型的对象。由于您已经创建了对工作表的引用,因此只需使用它。