2016-07-21 11 views
0

ランタイムエラー '1004'(アプリケーション定義またはオブジェクト定義エラー)が表示されます。それは2番目から最後のコード行で起きています。VBA Excelでランタイムエラー '1004'

また、私は同じコード行に回答を定義する方法を知っていますか?

Private Sub selectTable() 

Dim startingRow As Integer 
Dim endingRow As Integer 
Dim startingColumn As Integer 
Dim endingColumn As Integer 
Dim selectRow As Integer 
Dim selectColumn As Integer 

startingRow = 13 'This is the row where the table you are sihing to select starts 
startingColumn = 5 'This is the row where the table you are wishing to select starts 

endingRow = 0 'Variable to hold count of how many rows of data there are 
endingColumn = 0 'Variable to hold count of how many columns of data there are 

While Cells(startingRow, startingColumn) <> "" 'Counts number of rows that have data 
    endingRow = endingRow + 1 
    startingRow = startingRow + 1 
    Wend 

startingRow = 13 'This is the row where the table you are sihing to select starts 
startingColumn = 5 'This is the row where the table you are wishing to select starts 

While Cells(startingRow, startingColumn) <> "" 'Counts number of columns that have data 
    endingColumn = endingColumn + 1 
    startingColumn = startingColumn + 1 
    Wend 

startingRow = 13 'This is the row where the table you are sihing to select starts 
startingColumn = 5 'This is the row where the table you are wishing to select starts 

selectRow = startingRow + endingRow - 1 
selectColumn = startingColumn + endingColumn - 1 

Worksheets("General Information").Range(Cells(Row1, Col1), Cells(Row3, Col3)).Select 'Selects the entire range of the desired table 

End Sub 
+1

を定義していますか?あなたが投稿したコードには表示されません。 – sous2817

+0

私はすべての変数を変更し、それらを更新する必要があることを認識していない馬鹿です。ありがとうございました! – Saverio

+0

Googleの「VBA Option Explicit」は、そのようなことを支援します。 – sous2817

答えて

関連する問題