Hey guys, so I have been experimenting with userforms and I created a basic one which inputs data fine (all seems to be working when I run it). I have a frame with 2 option buttons in though and I wanted to make it so the user is forced to select one of them, I managed to write something which produces a msgbox if the user doesn't select one but it still creates the row of data which I don't want it to do. I've been reading a bunch of other questions and their examples don't seem to translate to mine. Not sure how to get it to not post the data without one of the buttons pressed?
Attached my sample workbook. The code though is:
Private Sub SUBMIT_Click()
Select Case True
Case Not OptionButton1 And Not OptionButton2
MsgBox "Frame 1 is missing a selection. ", vbExclamation, "Missing Entry"
Case Else
'All frames have been selected
End Select
Dim lngRow As Long
Worksheets("Sheet1").Activate
lngRow = Worksheets("Sheet1").Range("A1048576").End(xlUp).Row + 1
Cells(lngRow, 1) = FirstNametxt.Value
Cells(lngRow, 2) = LastNametxt.Value
Cells(lngRow, 3) = Notestxt.Value
Cells(lngRow, 4) = MarketingStatus.Value
Cells(lngRow, 4).Activate
End Sub
I actually also want it to prevent the user posting the data unless all the fields have something in them. Any ideas?
Bookmarks