Edit to working userform info

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,738
Office Version
  1. 2007
Platform
  1. 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

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
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

Forum statistics

Threads
1,223,908
Messages
6,175,306
Members
452,633
Latest member
DougMo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top