Userform copy value

johnster

New Member
Joined
May 31, 2018
Messages
43
In my UserForm is a dropbox with multiple names like Emergency, Maintenance, HR, .. and 2 textboxes.
Is there a vba code to lookup the dropbox value and paste the 2 textbox values under the dropboxvalue in the sheet.

See screenshot https://imgur.com/a/riaakva


Thx in advance
riaakva
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Assuming these search for values are in column A of the active sheet

Try this:
Assuming your Combobox is named Combobox1
And your Textboxes are named Textbox1 and Textbox2

If these assumptions are not correct modify the script or Provide specific details.

Code:
Private Sub CommandButton2_Click()
'Modified  10/19/2018  10:42:36 PM  EDT
Dim SearchRange As Range
Dim Lastrow As Long
Lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Set SearchRange = Range("A1:A" & Lastrow).Find(ComboBox1.Value)
If SearchRange Is Nothing Then MsgBox "The Value  " & ComboBox1.Value & "  Not Found": Exit Sub
SearchRange.Offset(1).Value = TextBox1.Value
SearchRange.Offset(2).Value = TextBox2.Value
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,915
Messages
6,122,212
Members
449,074
Latest member
cancansova

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