2013-05-01 221 views
-1

我不斷收到一個「類型不匹配」錯誤13上線IRow = ...更改列順序?

我想知道如何可以修復此代碼?

I als

此致敬禮。

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

變化

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

iRow = data_sheet1.UsedRange.Rows.Count 

Sheets(index)預計index是一個表名稱或索引號。但是您傳遞的是Worksheet類型的對象。由於您已經創建了對工作表的引用,因此請使用它。

+0

非常感謝! – user1717622 2013-05-02 11:34:47