我正在创建一个共享工作表 - 在 O 列中,当他们单击时,我创建了一个用户表单,询问 3 个问题。我需要将这些答案放入隐藏的工作表中。我已经编写了代码,但是当我运行它时,我得到了编译错误方法。由于我对 VBA 很陌生,我确定我错过了一些我不明白的东西。我错过了各种错误。这是我的第一个,我还没有复制和粘贴。所以任何帮助将不胜感激!在这种情况下,我在谷歌上搜索并找到了一个关于我正在寻找的表格,并尝试对其进行调整以适应我需要的内容。可能是我的第一个错误!
它突出了
iRow = ws.Cells.Find(What:="*", SearchOrder:=x1Rows, _
SearchDirection:=x1Previous, LookIn:=x1Values).Row + 1
这是我的整个代码。请帮忙!
Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("WebLeadInfo")
'find first empty row database
iRow = ws.Cells.Find(What:="*", SearchOrder:=x1Rows, _
SearchDirection:=x1Previous, LookIn:=x1Values).Row + 1
'check for a contact
If Trim(Me.txtContact.Value) = " " Then
Me.txtContact.SetFocus
MsgBox "Please enter info"
Exit Sub
End If
'copy the data to the database
'use protect and unprotect lines,
' with your password
' if worksheet is protected
With ws
' .Unportect Password:="sunway12"
.Cells(lRow, 1).Value = Me.txtContact.Value
.Cells(lRow, 3).Value = Me.txtFind.Value
.Cells(lRow, 4).Value = Me.txtSearch.Value
.Protect Password:="sunway12"
End With
'clear the data
Me.txtContact.Value = " "
Me.txtFind.Value = " "
Me.txtSearch.Value = " "
Me.txtContact.SetFocus
End Sub
Private Sub cmdClose_Click()
Unload Me
End Sub