ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,806
- Office Version
- 2007
- Platform
- Windows
Afternoon,
I have a working userform which the code is shown here.
I have now added the TextBox1 to the userform as shown in photo supplied.
When i type a value in the TextBox once the command button is pressed this value should be entered in cell A34
Can you advise please how i edit the code so both comboboxes & textbox must be complete where at present its just set up for combobox.
Also how we send the value to cell A34
Many thansk & have a nice day
I have a working userform which the code is shown here.
VBA Code:
Private Sub TransferButton_Click()
Dim i As Integer
Dim ControlsArr As Variant, ctrl As Variant
Dim x As Long
For i = 1 To 2
With Me.Controls("ComboBox" & i)
If .ListIndex = -1 Then
MsgBox "MUST SELECT ALL OPTIONS", 48, "MONTH,YEAR & MILEAGE TRANSFER MESSAGE"
.SetFocus
Exit Sub
End If
End With
Next i
ControlsArr = Array(Me.ComboBox1, Me.ComboBox2)
With ThisWorkbook.Worksheets("MILEAGE")
For i = 0 To UBound(ControlsArr)
Select Case i
Case 1, 2, 4
.Cells(1, i + 3) = IIf(IsNumeric(ControlsArr(i)), Val(ControlsArr(i)), ControlsArr(i))
Case Else
.Cells(1, i + 2) = ControlsArr(i)
ControlsArr(i).Text = ""
End Select
Next i
End With
ActiveWorkbook.Save
Application.ScreenUpdating = True
MsgBox "Month,Year & Mileage Have Been Updated", vbInformation, "SUCCESSFUL MILEAGE MESSAGE"
Unload MYFMILEAGE
End Sub
I have now added the TextBox1 to the userform as shown in photo supplied.
When i type a value in the TextBox once the command button is pressed this value should be entered in cell A34
Can you advise please how i edit the code so both comboboxes & textbox must be complete where at present its just set up for combobox.
Also how we send the value to cell A34
Many thansk & have a nice day