Consulting

Results 1 to 14 of 14

Thread: Offsetting Multiple VLookups with Picklists

  1. #1
    VBAX Regular
    Joined
    Jul 2008
    Posts
    40
    Location

    Offsetting Multiple VLookups with Picklists

    Hi All,

    Have a look at the file I have attached. I am trying to use 2 picklists and 2 Vlookups so that if the 1st Picklist is selected I get the result in the 2nd Picklist and visa versa if the 2nd Picklist is selected I get the result in the 1st Picklist.

    Thank for your help.

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Not without VBA, or you would create a circular loop.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Couldn't you just blank out one or the other and use

    =IF(B3<>"",formula1,IF(B4<>"",formula2,""))
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  4. #4
    VBAX Regular
    Joined
    Jul 2008
    Posts
    40
    Location
    Hi xld,

    Can you put your idea in the attached file so I can see what you mean?

    Thanks.

  5. #5
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    I would need more from you before I can do that as I was not clear what you would be looking up from B3 and/or B4.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  6. #6
    VBAX Regular
    Joined
    Jul 2008
    Posts
    40
    Location
    You've lost me, can't you just use the a,b,c and 1,2,3 data in the table?

    Thanks.

  7. #7
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Use it where, how?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  8. #8
    VBAX Regular
    Joined
    Jul 2008
    Posts
    40
    Location
    Hi,

    Maybe our wires are crossed. If I select 'a' from the first Picklist I get '1' in the second Picklist, and the same with 'b' I get '2' etc.

    As well as this I want the ability to select any of the numbers from the second Picklist, like '3' and get the result 'c' in the first Picklist.

    Thanks.

  9. #9
    Moderator VBAX Master georgiboy's Avatar
    Joined
    Mar 2008
    Location
    Kent, England
    Posts
    1,198
    Location
    So let me get this straight you want it so that when you select "e" in the first picklist you want the vlookup formula to display "5" and if you selected say "6" in the second picklist the vlookup formula would display "f", is that correct?
    Click here for a guide on how to add code tags
    Click here for a guide on how to mark a thread as solved
    Click here for a guide on how to upload a file with your post

    Excel 365, Version 2403, Build 17425.20146

  10. #10
    Moderator VBAX Master georgiboy's Avatar
    Joined
    Mar 2008
    Location
    Kent, England
    Posts
    1,198
    Location
    oh i see, i believe as XLD said you would get a circular reference. What is the use of the Vlookup then?
    Click here for a guide on how to add code tags
    Click here for a guide on how to mark a thread as solved
    Click here for a guide on how to upload a file with your post

    Excel 365, Version 2403, Build 17425.20146

  11. #11
    VBAX Regular
    Joined
    Jul 2008
    Posts
    40
    Location
    Hi,

    Is there no way of putting the formulas somewhere else, so the formulas are in different cells to the results?

    Thanks.

  12. #12
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Then you need VBA event code as MD suggested

    [vba]

    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim idx As Long

    Application.EnableEvents = False

    If Target.Address = "$B$3" Then

    idx = Application.Match(Target.Value, Me.Range(Right$(Target.Validation.Formula1, Len(Target.Validation.Formula1) - 1)), 0)
    Me.Range("B4").Value = Application.Index(Me.Range(Right$(Range("B4").Validation.Formula1, Len(Range("B4").Validation.Formula1) - 1)), idx)
    ElseIf Target.Address = "$B$4" Then

    idx = Application.Match(Target.Value, Me.Range(Right$(Target.Validation.Formula1, Len(Target.Validation.Formula1) - 1)), 0)
    Me.Range("B3").Value = Application.Index(Me.Range(Right$(Range("B3").Validation.Formula1, Len(Range("B4").Validation.Formula1) - 1)), idx)
    End If

    Application.EnableEvents = True

    End Sub
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  13. #13
    Moderator VBAX Master georgiboy's Avatar
    Joined
    Mar 2008
    Location
    Kent, England
    Posts
    1,198
    Location
    Not without VBA, or you would create a circular loop.
    I meant to say MD sorry
    Click here for a guide on how to add code tags
    Click here for a guide on how to mark a thread as solved
    Click here for a guide on how to upload a file with your post

    Excel 365, Version 2403, Build 17425.20146

  14. #14
    VBAX Regular
    Joined
    Jul 2008
    Posts
    40
    Location
    Hi xld,

    That works perfect, but due to restrictions I can't use VBA. Can there possibly be answer without using VBA?

    Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •