Hello Guys,
I created a spreadsheet with a custom form to collect data by operators. (Displayed Spreadsheet is generalized)
An operator can enter their name in a textbox, select an item from the combo box and enter a value into the textbox next to it. What I am struggling with is whatever item is selected in the combo box (cmb1) it should put the value entered in the textbox (txtstat1) next to it, into the respective column on the Database sheet. It is not doing that. See my listed code:
Ex)
Operator Jeff enters the following information:
cmb1: Option 1
cmb2: Option 2
cmb3: Option 6
txtstat1: 23
txtstat2: 38
txtstat3: 56
Please see "Database Example Result" Attachment for desired result.
VBA
Sub Enter()
Dim sh As Worksheet
Dim iRow As Long
Set sh = ThisWorkbook.Sheets("Database")
If Start.txtRow.Value = "" Then
iRow = [Counta(Database!A:A)] + 1
Else
iRow = Start.txtRow.Value
End If
With sh
'Take value in textbox and move to where Combobox is selected
Dim ResultCol As Variant
If Not IsEmpty(Cells(iRow, 1)) Then
ResultCol = Application.Match(Start.cmb1.Value, ActiveWorkbook.Sheets("Database").Range("A:A"), 0)
ActiveWorkbook.Sheets("Databse").Cells(iRow + 1, ResultCol).Value = Start.txtstat1.Value
End If
End With
End Sub
Display More
Any feedback is much appreciated!!!