我正在尝试将新数据行添加到excel表中。但是,这样做时会发生一些错误。
添加新行的代码:
Private Sub CommandButton54_Click()
Dim ws As Worksheet
Set ws = Sheets("Worksheet1")
Dim tbl As ListObject
Set tbl = ws.ListObjects("Table1")
Dim newrow As ListRow
Set newrow = tbl.ListRows.Add
With newrow
.Range(3) = Me.Add1
.Range(4) = Me.Add2
.Range(5) = Me.Add3
.Range(6) = Me.Add4
End With
但是,当我添加新行并退出用户表单时,下次我尝试打开用户表单时,会出现运行时错误13,并且文件在关闭时崩溃。