Transfer Data from texbox in userform to another textbox in other userform

jdcar

Board Regular
Joined
Apr 27, 2012
Messages
160
Again Hi everyone
I have a combo box (cbo1); text box (txt1); text box (txt2) and command box (cmd1) in userform2.

and I have another userform (userform1) where I have a text box (txtobs) and a text box (txtVal).

The objective is: 1 - the cbo1 data in userform2, after selecting the item, goes to userform1's txtobs.

2 - the same as txt2 in userform2, after being entered, goes to txtVal of userform1.

3 - in txt1 in the user2 form, the text in this box completes the information of the cbo1, in the txtobs of form1.

*** and here I need your help.

with the code below, solved (1 and 2), but with objective 3, I don't know how to do it.

Please thank you very much for your help.
VBA Code:
Private Sub cbo1_Change()



Dim i As Long, lastrow As Long, ws As Worksheet

Set ws = Sheets("tabs2")

lastrow = ws.Range("A" & Rows.count).End(xlUp).Row

For i = 2 To lastrow

If Me.cbo1.Value = ws.Cells(i, "f") Then

UserForm1.txtobs = ws.Cells(i, "f").Value & " - " '& ***

End If

Next i



End Sub



Private Sub cmdTransf_Click()

UserForm1.txtval.Value = Me.txt2.Value

Unload Me

End Sub



Private Sub UserForm_Initialize()



Dim i As Long, lastrow As Long, ws As Worksheet

Set ws = Sheets("tabs2")

lastrow = ws.Range("f" & Rows.count).End(xlUp).Row

For i = 2 To lastrow

Me.cbo1.AddItem ws.Cells(i, "f").Value

Next i

End Sub
 

jdcar

Board Regular
Joined
Apr 27, 2012
Messages
160
Hi Dante
Yes. I think it is precisely in that line.
The data is written at the time you fill out Form2, such as making a short comment or giving short directions or giving advice etc. . It has no pre-defined data.
What is intended is, in fact, to introduce both what is defined in cbo1 as well as what is written in txt1 of userform2.
Thank again, and I'm sorry for this inconvenience.
 

Some videos you may like

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
12,594
Office Version
  1. 2007
Platform
  1. Windows
Try this

VBA Code:
Private Sub cmdTransf_Click()
UserForm1.txtVal.Value = Me.txt2.Value
UserForm1.txtObs = UserForm2.cbo1.Value & " - " & UserForm2.txt1.Value
unload me
End Sub

If that doesn't work for you, then you could upload a copy of your book to understand what you have and how you have your userforms.

You could upload a copy of your file to a free site such www.dropbox.com or google drive. Once you do that, mark it for 'Sharing' and you will be given a link to the file that you can post here. If the workbook contains confidential information, you could replace it with generic data.
 

jdcar

Board Regular
Joined
Apr 27, 2012
Messages
160
hi Dante
It actually worked with the code below and removing the instructions exposed in cbo1.
Thank you very much for your patience.
solved
VBA Code:
Private Sub txt1_Change()
UserForm1.txtObs.Value = UserForm2.cbo1.Value & " - " & UserForm2.txt1.Value
End Sub
 

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
12,594
Office Version
  1. 2007
Platform
  1. Windows
I'm glad to help you. Thanks for the feedback.
 

Watch MrExcel Video

Forum statistics

Threads
1,123,206
Messages
5,600,317
Members
414,376
Latest member
NickYOW

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
Top