inactiveUser214710
Board Regular
- Joined
- Apr 27, 2012
- Messages
- 171
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.
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