我已经创建工作的目的本投资者邮件列表,需要添加一些更多的功能:VBA的输入框擅长
我需要“锁定”的输入框,这意味着你必须否则填写所有选项msgbox会发生“请填写所有选项”。
我还需要锁定整个电子表格 - 所以只能通过输入框将投资者添加到邮件列表中。它应该只可能没有输入框通过管理员
我已经搜索所有在互联网上新增投资者,并不能找到这样的功能
帮助深表感谢!
Private Sub OKButton_Click()
Dim emptyrow As Long
'Make sheet1 active
Ark1.Activate
'determine emptyrow
emptyrow = WorksheetFunction.CountA(Range("A:A")) + 1
'Transfer information
Cells(emptyrow, 1).Value = Email.Value
Cells(emptyrow, 2).Value = Bank.Value
Cells(emptyrow, 3).Value = FirstName.Value
Cells(emptyrow, 4).Value = Surname.Value
Cells(emptyrow, 5).Value = AddIn.Value
Cells(emptyrow, 6).Value = TypeComboBox.Value
If CheckBox1.Value = True Then Cells(emptyrow, 7).Value = CheckBox1.Caption
If CheckBox2.Value = True Then Cells(emptyrow, 7).Value = Cells(emptyrow, 7).Value & " " & CheckBox2.Caption
If CheckBox3.Value = True Then Cells(emptyrow, 7).Value = Cells(emptyrow, 7).Value & " " & CheckBox3.Caption
If CheckBox4.Value = True Then Cells(emptyrow, 7).Value = Cells(emptyrow, 7).Value & " " & CheckBox4.Caption
If CheckBox5.Value = True Then Cells(emptyrow, 7).Value = Cells(emptyrow, 7).Value & " " & CheckBox5.Caption
Unload Me
MsgBox "Investor successfully added"
End Sub
Private Sub UserForm_Click()
End Sub
Private Sub UserForm_Initialize()
'empty all textboxes
Email.Value = ""
Bank.Value = ""
FirstName.Value = ""
Surname.Value = ""
AddIn.Value = ""
TypeComboBox.Clear
'Fill dinnercombobox
With TypeComboBox
.AddItem "Bank"
.AddItem "Corporate"
.AddItem "DCM"
.AddItem "Fund Manager"
.AddItem "FSA"
.AddItem "Investor"
.AddItem "Insurance"
.AddItem "Magazine"
.AddItem "Other"
.AddItem "Pension Fund"
.AddItem "Rating agency"
End With
'uncheck wishbox
CheckBox1.Value = False
CheckBox2.Value = False
CheckBox3.Value = False
CheckBox4.Value = False
'set focus on email box
Email.SetFocus
End Sub
您应该在'Textboxes'更改事件中添加一个嵌套的if,以检查值是否存在。要锁定工作表,您可以在'Workbooks'open事件中执行此操作,以保护'UserInterfaceOnly'中的工作表设置为“True”。 – L42
你能指定那个吗?我在编码时非常绿色 – user3168488
我现在已经想出了如何锁定单元格,所以你只能通过输入框输入,我仍然需要直到弄清楚如何只填写整个输入框 – user3168488