How can i match information from pages using Drop-Down List

Capy_Uther

New Member
Joined
May 14, 2023
Messages
16
Office Version
  1. 365
Platform
  1. Windows
Hello to everyone guys i would like to add the following to my excel

I have a Page called "Vendedores" with the following table: ( On this table i have all the information i need)

1684781258035.png


On a second page Called "pag1" i have a drop down list with the information on the table before

1684781338963.png

The thing with this table is that on the Drop Down menu i can see the names, but if i choose a name instead of show the name on that cell "N2" it shows the number
Example if i choose Kevin Oliveros instead of show the name it will show the number 12 because is the number on the table for that name.
For this to work i use the follow code:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim Changed As Range, c As Range

Set Changed = Intersect(Target, Range("N2")) '<- Edit range as required
If Not Changed Is Nothing Then
Application.EnableEvents = False
For Each c In Changed
If Len(c.Value) > 0 Then
c.Value = Sheets("Vendedores").Range("A2:A500").Find(What:=c.Value, LookAt:=xlWhole, MatchCase:=False).Offset(, 1).Value
End If
Next c
Application.EnableEvents = True
End If
End Sub

Everything until now works great now with all that information i would like to add the when i choose a name on the drop down menu on page "pag1" also on that same page prints the following:

in cell "A6", "E-mail:" and the email for the person selected according the table at the begining of this post

In cell "A7", "Asesor de Ventas:" and the name of the person selected on the drop down list

As an example on the drp down list if i choose Kevin Oliveros it will be like this on A6 and A7

1684781750928.png
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
VBA Code:
    Dim Found As Range
    Set Changed = Intersect(Target, Range("N2"))    '<- Edit range as required
    If Not Changed Is Nothing Then
        Application.EnableEvents = False
        For Each c In Changed
            If Len(c.Value) > 0 Then
                Set Found = Sheets("Vendedores").Range("A2:A500").Find(What:=c.Value, LookAt:=xlWhole, MatchCase:=False)
                c.Value = Found.Offset(, 1).Value
                Range("A6").Value = "E-mail: " & Found.Offset(, 2).Value
                Range("A7").Value = "Asesor de Ventas: " & Found.Value
            End If
        Next c
        Application.EnableEvents = True
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,183
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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