ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,832
- Office Version
- 2007
- Platform
- Windows
The code supplied below is for 7 Textboxes.
I have removed 2 of the Texboxes & replaced them with ComboBox1 & ComboBox2
When i now try to transfer data from userform to worksheet i see a msg telling me basicslly that i did not enter anything in the first ComboBox.
How cam i add an edit to also allow it to accept the added ComboBoxes
I have removed 2 of the Texboxes & replaced them with ComboBox1 & ComboBox2
When i now try to transfer data from userform to worksheet i see a msg telling me basicslly that i did not enter anything in the first ComboBox.
How cam i add an edit to also allow it to accept the added ComboBoxes
Code:
Private Sub CommandButton2_Click() Dim i As Integer
Dim LastRow As Long
Dim wsGRASS As Worksheet
Set wsGRASS = ThisWorkbook.Worksheets("GRASS")
For i = 1 To 7
With Me.Controls("TextBox" & i)
If .Text = "" Then
MsgBox Choose(i, "Name", "Where Advert Was Seen", "Telephone Number", _
"Post Code", "Area", "Price Paid", "Date") & _
" Not Entered", vbCritical, "GRASS CUTTING SHEET"
.SetFocus
Exit Sub
End If
End With
Next i
With wsGRASS
LastRow = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
End With
For i = 1 To 7
With Me.Controls("TextBox" & i)
wsGRASS.Cells(LastRow, i * 2).Value = .Text
.Text = ""
End With
Next i
MsgBox "GRASS SHEET UPDATED", vbInformation, "GRASS CUTTING SHEET"
TextBox1.SetFocus
End Sub