View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
VB Newbie[_2_] VB Newbie[_2_] is offline
external usenet poster
 
Posts: 21
Default Attempting to reduce userforms

Or would Cells(1, r).offset(0,11) and Cells(2, r).offset(0,11) be a better
idea?

"chijanzen" wrote:

VB Newbie:

add this code to Userform2

'Userform2
Private Sub CommandButton1_Click()
Dim Ctrl As MSForms.Control
Dim ob As String
For Each Ctrl In UserForm1.Controls
If TypeName(Ctrl) = "OptionButton" And Ctrl = True Then
ob = Ctrl.Name
End If
Next
r = Val(Right(ob, 1))
Cells(1, r) = Me.TextBox1.Text
Cells(2, r) = Me.TextBox2.Text
End Sub

--
天行健,君*以自強不息
地勢坤,君*以厚德載物

http://www.vba.com.tw/plog/


"VB Newbie" wrote:

Dear anyone who would like to assist-

I think I can reduce the number of userforms by 75-80%, however I can't find
a quick fix to my issue. Here is what I have thus far.

Userform1 with 4 optionbuttons.
Userform2 with 2 textboxes and a commandbutton.

Each optionbutton will open up Userform2. If optionbutton1 is selected, I
want the textboxes to place their values in A1 and A2, OB2 to B1 and B2, OB3
to C1 and C2, and OB4 to D1 and D2 using commandbutton1.

Is this feasible using scripts in Userform2 or do I need to set up
individual scripts for each optionbutton?

Any help would be greatly appreciated!!