Userform Help!!

Excelnoobisme

Board Regular
Joined
Nov 19, 2010
Messages
128
Hi,

I have 5 optionbutton and 1 textbox and 1 command button.

The 5 optionbutton are name "A,B,C,D,E" and the textbox is for inputting amount.

how can i set it as if Optionbutton A is selected and amount key in, when i press ok it will paste the amount in Cell A1. If the next amount is still with optionbutton A, the amount will be paste in Cell A2.

If optionbutton C is selected next, the amount will be key in on Cell C1.

and so on.....

Thanks
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Maybe something along these lines:-
Code:
[FONT=Fixedsys]Option Explicit[/FONT]
 
[FONT=Fixedsys]Private Sub [COLOR=red]CommandButton1[/COLOR]_Click()[/FONT]
 
[FONT=Fixedsys]  Dim btn As Control[/FONT]
[FONT=Fixedsys]  Dim iLast As Long[/FONT]
 
[FONT=Fixedsys]  For Each btn In [COLOR=red]UserForm1[/COLOR].Controls[/FONT]
[FONT=Fixedsys]    If btn.Value = True Then[/FONT]
[FONT=Fixedsys]      iLast = Cells(Rows.Count, btn.Name).End(xlUp).Row[/FONT]
[FONT=Fixedsys]      If IsEmpty(Range(btn.Name & iLast)) Then iLast = iLast - 1[/FONT]
[FONT=Fixedsys]      Range(btn.Name & iLast + 1) = [COLOR=red]TextBox1.Value[/COLOR][/FONT]
[FONT=Fixedsys]    End If[/FONT]
[FONT=Fixedsys]  Next btn[/FONT]
 
[FONT=Fixedsys][COLOR=red]  TextBox1[/COLOR] = ""[/FONT]
 
[FONT=Fixedsys]End Sub[/FONT]
(This assumes that you've used the names UserForm1, CommandButton1 and TextBox1. Code tested and working here.)
 
Upvote 0

Forum statistics

Threads
1,224,527
Messages
6,179,328
Members
452,907
Latest member
Roland Deschain

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