Using checkbox in userform

mmaeng13

New Member
Joined
Aug 29, 2017
Messages
25
Hello,

I am using a UserForm for data entry with eRow commands. Within the UserForm I have some check boxes. How do I output a Y or N result from the UserForm using eRow commands or is there an easier way to output the results? I am a VBA coding novice, as in I have worked my way through using forums and other sites.
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Hello,

I am using a UserForm for data entry with eRow commands. Within the UserForm I have some check boxes. How do I output a Y or N result from the UserForm using eRow commands or is there an easier way to output the results? I am a VBA coding novice, as in I have worked my way through using forums and other sites.

I don't know what is eRow but an easy way to get your result might be this:
Code:
If Userform1.CheckBox1 Then      ' Adjust Form name and CB name
   myResult = "Y"
Else
   myResult = "N"
End If

Bye
 
Upvote 0
Here is a section of the eRow commands I am using.

Private Sub Enter_Click()


eRow = Sheet3.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
Cells(eRow, 1).Value = Day.Text
Cells(eRow, 2).Value = PMEHours.Text
Cells(eRow, 3).Value = PMEGallons.Text
Cells(eRow, 4).Value = SMEHours.Text
Cells(eRow, 5).Value = SMEGallons.Text

End Sub
 
Upvote 0
You are doing your best trying to confuse the audience...

So "eRow" is a variable; now I guess "ENTER" is the name you assigned to a commandbutton on your userform, "Day", "PMEHours" etc are the names of some textboxes on the same userform.

You didn't say where now the Y or N should be outputted to, so let me invent this info is needed in column 6 and 7; nor you wrote how you named your checkboxes, so let me invent they are CheckBox1 and CheckBox2.

If this is the case, then add these lines to your code:
Code:
Cells(eRow, 5).Value = SMEGallons.Text
If CheckBox1 then Cells(eRow, 6).Value = "Y" Else Cells(eRow, 6).Value = "N"      'ADD THIS
If CheckBox2 then Cells(eRow, 7).Value = "Y" Else Cells(eRow, 7).Value = "N"      'ADD THIS
'more lines as above if needed

End Sub
 
Last edited:
Upvote 0
You are doing your best trying to confuse the audience...

So "eRow" is a variable; now I guess "ENTER" is the name you assigned to a commandbutton on your userform, "Day", "PMEHours" etc are the names of some textboxes on the same userform.

You didn't say where now the Y or N should be outputted to, so let me invent this info is needed in column 6 and 7; nor you wrote how you named your checkboxes, so let me invent they are CheckBox1 and CheckBox2.

If this is the case, then add these lines to your code:
Code:
Cells(eRow, 5).Value = SMEGallons.Text
If CheckBox1 then Cells(eRow, 6).Value = "Y" Else Cells(eRow, 6).Value = "N"      'ADD THIS
If CheckBox2 then Cells(eRow, 7).Value = "Y" Else Cells(eRow, 7).Value = "N"      'ADD THIS
'more lines as above if needed

End Sub

Still very new to the coding side of Excel, I will do my best to remember the terminology. All of you assumptions on what I am doing are spot on. It worked perfectly for me. I have mostly just done equations and formatting in excel cells to get my results, VBA has actually made things a lot easier.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,322
Members
452,635
Latest member
laura12345

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