Userform with Radio buttons and texbox's

solo2070

New Member
Joined
Feb 28, 2009
Messages
15
I will try to describe what I am doing. I have been doing searches and not finding an answer that works. Also, I may be going about this the wrong way, but I am trying to keep it simple.

I have a userform I am creating that has 6 fields for users the enter data in. This data is then put into a worksheet. However, I only have 5 spots for data. 2 of the text boxes in the userform need to be and either or thing.

Here is my code thus far:

Code:
Private Sub CommandButton1_Click()

'copies data to the next row
'enters the roomtype
Range("C90").Select
    Selection.End(xlUp).Offset(1, 0) = ComboBox1.Text
'Enters the description
    'Cells(nextrow, 2) = TextBox1.Text
Range("c90").Select
    Selection.End(xlUp).Offset(0, 1) = TextBox1.Text
'Enters the Floor type
Range("c90").Select
    Selection.End(xlUp).Offset(0, 2) = ComboBox2.Text
'Enters the Amount
'Range("c90").Select
    'Selection.End(xlUp).Offset(0, 3) = TextBox1.Text
'Enters the Weekly Frequency
Range("c90").Select
    Selection.End(xlUp).Offset(0, 5) = TextBox2.Text

'settles on the new record based off of the first column
Range("c90").Select
Selection.End(xlUp).Select

'clears form
Unload Me
    Data_entry_assist.Show

End Sub

It is the "Amount" portion where I am needing the data to go. I thought I could put a radio button by each textbox in the userform and then have the data next to the selected radio button be the one that gets entered. Seemed like it would be a simple enough process for the end user, but I for the life of me can not figure out how to make this work.

I hope that makes sense.
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Instead of indicating which text box to use, perhaps you could make it so that only one textbox can have a value entered.

Code:
Private Sub TextBox1_Change()
    TextBox2.Enabled = (TextBox1.Text = vbNullString)
End Sub

Private Sub TextBox2_Change()
    TextBox1.Enabled = (TextBox2.Text = vbNullString)
End Sub
 
Upvote 0
I like that idea, and I will try it now. But how do I then handle the sending of that data to the worksheet. I am not sure I know how to code which will go where. Do I code it where if one is empty than it does nothing?
 
Upvote 0
Just tried it. It works as long as you don't change your mind. I can't make a change once the box has been disabled.
 
Upvote 0

Forum statistics

Threads
1,224,568
Messages
6,179,595
Members
452,927
Latest member
whitfieldcraig

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