-1

我在 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
4

1 回答 1

0

改变

iRow = Sheets(data_sheet1).UsedRange.Rows.Count

iRow = data_sheet1.UsedRange.Rows.Count

Sheets(index)期望index是工作表名称或索引号。但是您传递的是 Worksheet 类型的对象。由于您已经创建了对工作表的引用,请使用它。

于 2013-05-01T18:20:34.457 回答