0
Ich erhalte einen Laufzeitfehler '1004' (anwendungsdefinierter oder objektdefinierter Fehler). Es passiert in der vorletzten Codezeile.Laufzeitfehler '1004' auf VBA Excel
Weiß auch jemand, wie man die Antwort definiert, die ich auf der gleichen Linie des Codes erhält?
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
sind Row1, Row3, Col1 und Col3 überall definiert? Ich sehe sie nicht in dem Code, den Sie gepostet haben. – sous2817
Ich bin ein Idiot haha Ich habe alle Variablen geändert und nicht realisiert, dass ich diese aktualisieren musste. Vielen Dank! – Saverio
Google "VBA Option Explicit", um mit solchen Dingen zu helfen. – sous2817