0
這部分代碼旨在調整表格的大小,以便從用戶窗體添加新的數據輸入行。目前,當我運行的代碼,我得到:調整表格範圍
錯誤9 - 下標越界
就行了:
Set tbl1 = sht1.ListObjects("LogTable")
這是全碼:
Private Sub CommandButton1_Click()
'Start button
'Log start time as the time the button is clicked
Dim EmptyRow, LastRow As Long
Dim sPath As String
Dim tbl1, tbl2 As Range
'Find next empty row based on first column
Set wb = ThisWorkbook
Set sht1 = wb.Sheets("Log")
Set tbl1 = sht1.ListObjects("LogTable")
LastRow = sht1.Cells(sht1.Rows.Count, "A").End(xlUp).Row
EmptyRow = LastRow + 1
tbl1.Resize Range("A2:E" & EmptyRow)
sht1.Cells(EmptyRow, 1).Value = Now
感謝您的幫助!
建議您沒有該名稱的表格。但表格自動調整大小。 – SJR