【发布时间】:2018-05-15 18:47:06
【问题描述】:
当代码到达“在数据库中查找第一个空行”时,它会以黄色突出显示接下来的两行并显示运行时错误 91。谁能告诉我哪里出错了。谢谢。
Private Sub diaryenter_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("sheet1")
'find first empty row in database
iRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
'copy the data to the database
With ws
.Cells(iRow, 115).Value = Me.autodatet.Value
.Cells(iRow, 116).Value = Me.fdcomments.Value
.Cells(iRow, 121).Value = Me.fdgs.Value
End With
'clear the data
Me.autodatet.Value = ""
Me.fdcomments.Value = ""
Me.fdgs.Value = ""
Diaryentryf.Hide
ThisWorkbook.Save
End Sub
【问题讨论】:
-
哪一行出现错误?
-
xlByRows不是xlRows。 -
Worksheets("sheet1") 中有数据吗?否则会报错
-
嗯,看起来有点眼熟...(它仍然不是数据库);-)
标签: vba excel runtime-error