Hi everyone, I was recently tasked to create a program for work and it was recommended to me that VBA would serve my purpose very well. Problem is, I don't have a programming background and have had no experience with VBA before this. I have relied heavily on google and ready made templates to help me but I am stumped on two aspects.
1) I need to link two or more drop down list together so that one selection will give different options in the next list (common question, I know but I can't get it to work...) and,
2) I need to create a link between a drop down list and check boxes. What happens is that by choosing and option in the drop down list, a selection pane will change to a checklist where I can mark the options I want.
All the information that is entered in the userform will then be updated into a descending list, with the checked options mentioned above placed into a single cell on an excel worksheet. I will include my code and a shot of the userform.
Private Sub CancelButton1_Click()
Unload Me
End Sub
Private Sub ClearButton_Click()
Call UserForm_Initialize
End Sub
Private Sub OKButton_Click()
Dim emptyRow As Long
'Make Summary Active
Sheets(2).Activate
'Determine EmptyRow
emptyRow = WorksheetFunction.CountA(Range("A:A")) + 1
'Export Data to worksheet
Cells(emptyRow, 1).Value = OperatorName.Value
Cells(emptyRow, 2).Value = Time.Value
Cells(emptyRow, 3).Value = Region.Value
Cells(emptyRow, 4).Value = Location.Value
Cells(emptyRow, 5).Value = Reference.Value
Cells(emptyRow, 6).Value = EmployeeNo.Value
Cells(emptyRow, 7).Value = DutyType.Value
Cells(emptyRow, 8).Value = TaskCategory.Value
Cells(emptyRow, 9).Value = Comments
Unload Me
End Sub
Private Sub UserForm_Initialize()
'Empty OperatorName
OperatorName.Value = ""
'Empty Time
Time.Value = ""
'Empty Reference
Reference.Value = ""
'Empty Region
Region.Value = ""
'Fill Region
With Region
.AddItem "1"
.AddItem "2"
.AddItem "3"
End With
'Empty Location
Location.Value = ""
'Empty EmployeeNo
EmployeeNo.Value = ""
'Empty Comments
Comments.Value = ""
'Empty DutyType
DutyType.Clear
'Fill DutyType
With DutyType
.AddItem "FL"
.AddItem "M"
.AddItem "FR"
.AddItem "X"
End With
'Empty TaskCategory
TaskCategory.Clear
'Set Focus on OperatorName
OperatorName.SetFocus
End Sub
I have included my sample excel file to those who wish to take a look, many of you will undoubtedly notice that I have copied a template wholesale for it. I am hoping to link region and location tabs so that I may populate the location list based on a selection from the region list. As for the check boxes, I am hoping to replace the Task Category list with it as I need to choose multiple options. Any help or suggestions is really appreciated. However, please bear in mind that I am a beginner in this so easy to understand advice is best. Thanks you very much!
Bookmarks