Lookup

mks

Board Regular
Joined
Aug 28, 2009
Messages
173
Hi,
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p>
I need the macros for lookup.
<o:p> </o:p>
I have drop down list ( List 1) in Cell “C2” and sheet name is “Location”.
<o:p> </o:p>
I have three drop menu for lookup named – List 1, List 2 & list 3 on same sheet “Location”.
<o:p> </o:p>
Range – List 1 = AE10:AE25, List 2 = AF10:AF25 & List 3 = AG10:AG25
<o:p> </o:p>
I have the following function, but I need the Macros if you can help me.
<o:p> </o:p>
= if(C2=””,””,Lookup(C2,List 1, List2)) - This function is Cell “C3”
= if(C2=””,””,Lookup(C2,List 1, List3)) - This function is Cell “C4”
<o:p> </o:p>
Thanks for our help
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Code:
Option Explicit

Private Sub myExample()
Dim myValue As Integer
Dim cell1 As Range
Dim cell2 As Range

On Error GoTo err

    myValue = Sheets("Location").[C2].Value
    Set cell1 = Sheets("Location").[C3]
    Set cell2 = Sheets("Location").[C4]
    
    If myValue = 0 Then
        cell1 = ""
        cell2 = ""
    Else
        cell1 = Application.Lookup(myValue, [List1], [List2])
        cell2 = Application.Lookup(myValue, [List1], [List3])
    End If
    
    Exit Sub

err:
    MsgBox err.Description, vbExclamation, "Error"

End Sub
 
Upvote 0
DauntingGecko,

Thanks


But it does not run itself, when I select the value from List 1 in Cell C2. I have to run macros to update value.
 
Upvote 0

Forum statistics

Threads
1,224,559
Messages
6,179,513
Members
452,921
Latest member
BBQKING

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