我已經創建工作的目的本投資者郵件列表,需要添加一些更多的功能: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