I'm trying to make a simple user form in Excel to enter the date that a staff member did a certain task. I have a spreadsheet that lists all of my staff down column B and I have a list of all the tasks along row 5.
I've created a form with a couple of combo boxes so I can select the staff member and also select the task. There is also a text box which I will type a date into.
What I need is when I click the "submit" button it will enter the date contained in the text box into the cell defined by the 2 selections in the combo boxes. If either of the combo boxes have nothing selected then no data should be entered into the spreadsheet when the button is clicked.
Dim nameRow As Integer
Dim job1col As Integer
nameRow = cbxStaffName.ListIndex + 6
job1col = cbxJob1.ListIndex + 3
ThisWorkbook.Sheets("Job Rotation").Cells(nameRow, job1col).Value = tbxDate.Value
The combo box containing the list of staff names is called cbxStaffName
. The combobox containg the jobs is cbxJob1
. The textbox containing the date I want to enter is named tbxDate
.
The combo boxes have been populated with data that exists on the spreadsheet, simply names down the left and jobs along the top. If for example Jim
did the job welding
I want to select Jim
from one combo box, select welding
from the other box and when I click the button the date will go into that cell on the spreadsheet.