Can you have two userforms transferring data to separate worksheets within the same Excel file?

Greenmanmark62

New Member
Joined
Feb 21, 2018
Messages
3
Hi All....I'm a complete newbie to VBA and userforms.

I have managed to create a userform and have managed to get the data to transfer to a worksheet...really chuffed!

I've then gone on to add another userform within the same excel file and want to transfer its specific data to a separate worksheet within the excel file.....

Is this possible?...and if so how do I do it?

Many thanks in advance for the education.
Regards, Mark
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Welcome to MrExcel!

If you fully specify the objects, your data will get to the correct place

Ie

Code:
ThisWorkbook.Sheets("Data2").Range("C5") = UserForm2.TextBox1.Text
 
Upvote 0
Just curious. Why do you need two UserForms?
I have one UserForm that can do a lot of things.
Have never needed two UserForms in same Workbook.
 
Upvote 0
I am compiling a Benefits Management document that incorporates a Benefits Register fed from a userform (Benefits Profile Template) and also want to include a Benefits Realisation Plan which uses a different userform, there are different fields needed for each of the userforms.


Just curious. Why do you need two UserForms?
I have one UserForm that can do a lot of things.
Have never needed two UserForms in same Workbook.
 
Upvote 0
Many thanks for the welcome and advice...

My 1st userform which is used as a Benefits Profile Template that populates a Benefits Register (Sheet 1) is coded as below and data is transferred ok :)
Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub CmdInput_Click()
Dim cNum As Integer
Dim X As Integer
Dim nextrow As Range
'change the number for the number of controls on the userform
cNum = 26
Set nextrow = Sheet1.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)


For X = 1 To cNum
nextrow = Me.Controls("ip" & X).Value
Set nextrow = nextrow.Offset(0, 1)
Next

Clear_Form

End Sub

Sub Clear_Form()
For Each ctrl In Me.Controls
Select Case TypeName(ctrl)
Case "TextBox"
ctrl.Text = ""
Case "ComboBox"
ctrl.ListIndex = -1
Case "CheckBox"
ctrl.Value = False

End Select

Next

End Sub

The 2nd userform I've created serves as an input to a Benefits Realisation Plan (Sheet 4), the code I've tried to use for this is below but I'm obviously not telling it where the data needs to be transferred :(
So would really appreciate direction.
Private Sub cmdClose2_Click()
Unload Me
End Sub
Private Sub CmdInput2_Click()
Dim cNum As Integer
Dim X As Integer
Dim nextrow As Range
'change the number for the number of controls on the userform
cNum = 17
Set nextrow = Sheet4.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)


For X = 1 To cNum
nextrow = Me.Controls("ip" & X).Value
Set nextrow = nextrow.Offset(0, 1)
Next

Clear_Form

End Sub

Sub Clear_Form()
For Each ctrl In Me.Controls
Select Case TypeName(ctrl)
Case "TextBox"
ctrl.Text = ""
Case "ComboBox"
ctrl.ListIndex = -1
Case "CheckBox"
ctrl.Value = False

End Select

Next

End Sub
 
Upvote 0

Forum statistics

Threads
1,214,615
Messages
6,120,538
Members
448,970
Latest member
kennimack

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