userform help

rhino4eva

Board Regular
Joined
Apr 1, 2009
Messages
234
I have a 2 sheet workbook
sheet1 has 2 columns with the labels doctors and email in the top row
each doctor has one email
sheet 2 is a sort of a pre-arranged stationary that I need to add the doctors name and email to before they print out

I have been able to create a userform with 2 comboboxes for name and email which fills the selected name and email into the correct cells on the second sheet

however I would like to drop the second combobox on the userform and somehow link the name chosen in the userform to the correct email

would be grateful for assistance please
 

Some videos you may like

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

=ODIN=

Active Member
Joined
Dec 3, 2009
Messages
288
I feel like i'm missing something here. Is there anything stopping you from using vlookup in your code to get the email associated with comboBox1's value?
 

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
16,762
Office Version
2013
Platform
Windows
Why do you think you need to use a UserForm?

Why not double click a cell on sheet(1) which will do exactly what you want.

Put Doctor names in Sheet(1) Column(A)
Put Doctor Email address in Sheet(1) Column (B)

Double click on Doctor name and then this script will put Doctor name in Sheet(2) Range("F6")
And put Doctors Email address in Sheet(2).Range("H8")

Modify this to your needs.

This is an auto sheet event script
Your Workbook must be Macro enabled
To install this code:
Right-click on the sheet tab
Select View Code from the pop-up context menu
Paste the code in the VBA edit window

Put this script in Sheet(1)

Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
'Modified  4/4/2019  2:52:06 AM  EDT
If Target.Column = 1 Then
Cancel = True
Sheets(2).Range("F6").Value = Target.Value
Sheets(2).Range("H8").Value = Target.Offset(, 1).Value
End If
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,102,447
Messages
5,486,954
Members
407,574
Latest member
Greso

This Week's Hot Topics

Top