2017-10-11 42 views
0

我在這裏得到一個編譯錯誤說「對象不支持此屬性或方法」上線4Excel中。細胞(X,Y)轉換

我猜測,在中。細胞X( x,y)不能被看作一個整數?我需要將這個變量類型更改爲?

Private Function FinalizeTemplate(col As Integer) 

    With Worksheets(1) 
     .cell(col, 2).Value = "A" 
     .Columns("A").ColumnWidth = 10.3 
     .cell(col + 1, 2).Value = "B" 
     .Columns("B").ColumnWidth = 14 
     .cell(col + 3, 2).Value = "C" 
     .Columns("C").ColumnWidth = 12.57 
     .cell(col + 4, 2).Value = "Type" 
     .Columns("D").ColumnWidth = 8 
     .cell(col + 5, 2).Value = "Valid/Invalid" 
     .Columns("E").ColumnWidth = 11.71 
    End With 

End Function 
+3

您需要使用'.Cells()',注意's'。 – BruceWayne

+0

哇...不知道我錯過了那個語法錯誤!謝謝! :) – Maldred

+0

@BruceWayne你知道如果可以用這樣的方法改變列寬度大小嗎? – Maldred

回答

0

按BruceWayne的評論,問題是它必須是.cells(),而不是。細胞()