03856me
Active Member
- Joined
- Apr 4, 2008
- Messages
- 297
I am using Exel 2007 and have a Userform for data entry. There are 8 different frames with each frame containing 5 option buttons. I would like to prevent the user from "adding" the item unless they have choosen one of the 5 option buttons in each frame, so they would get an error message saying they must choose the options before proceeding.
I have 8 different AddData routines for each frame, Frame1, Frame2, etc. How do I tell it to check the option buttons within each Frame to make sure one has been choosen? Here is an example of the code for one of the AddData rountines if that helps:
Private Sub AddData1()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Data")
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
ws.Cells(iRow, 1).Value = Me.txt_date.Value
ws.Cells(iRow, 2).Value = "Planer"
ws.Cells(iRow, 3).Value = "Breakdown Hoist Area"
ws.Cells(iRow, 4).Value = Me.cbo_shift.Value
ws.Cells(iRow, 5).Value = "Infeed Area"
ws.Cells(iRow, 7).Value = Me.txt_minutes1.Value
ws.Cells(iRow, 8).Value = Me.txt_NoteInfeedArea.Value
ws.Cells(iRow, 9).Value = Me.cbo_employee.Value
If opt_mech1.Value = True Then ws.Cells(iRow, 6).Value = "Mechanical"
If opt_elec1.Value = True Then ws.Cells(iRow, 6).Value = "Electrical"
If opt_oper1.Value = True Then ws.Cells(iRow, 6).Value = "Operator"
If opt_hu1.Value = True Then ws.Cells(iRow, 6).Value = "Hang Up"
If opt_other1.Value = True Then ws.Cells(iRow, 6).Value = "Other"
End Sub
Thanks in Advance for your help,
I have 8 different AddData routines for each frame, Frame1, Frame2, etc. How do I tell it to check the option buttons within each Frame to make sure one has been choosen? Here is an example of the code for one of the AddData rountines if that helps:
Private Sub AddData1()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Data")
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
ws.Cells(iRow, 1).Value = Me.txt_date.Value
ws.Cells(iRow, 2).Value = "Planer"
ws.Cells(iRow, 3).Value = "Breakdown Hoist Area"
ws.Cells(iRow, 4).Value = Me.cbo_shift.Value
ws.Cells(iRow, 5).Value = "Infeed Area"
ws.Cells(iRow, 7).Value = Me.txt_minutes1.Value
ws.Cells(iRow, 8).Value = Me.txt_NoteInfeedArea.Value
ws.Cells(iRow, 9).Value = Me.cbo_employee.Value
If opt_mech1.Value = True Then ws.Cells(iRow, 6).Value = "Mechanical"
If opt_elec1.Value = True Then ws.Cells(iRow, 6).Value = "Electrical"
If opt_oper1.Value = True Then ws.Cells(iRow, 6).Value = "Operator"
If opt_hu1.Value = True Then ws.Cells(iRow, 6).Value = "Hang Up"
If opt_other1.Value = True Then ws.Cells(iRow, 6).Value = "Other"
End Sub
Thanks in Advance for your help,