+ Reply to Thread
Results 1 to 11 of 11

Named range in VBA Vlookup?

  1. #1
    Valued Forum Contributor Macdave_19's Avatar
    Join Date
    03-14-2007
    Location
    Birmingham, England
    MS-Off Ver
    12.0
    Posts
    808

    Named range in VBA Vlookup?

    Chik wee (as Borat might say),

    I'm wondering? is there any way that you can use a named range for the array in a vlookup that is done in VBA?

    my named range is "Lists" and here's my code:

    Please Login or Register  to view this content.
    As ever people, thanks for looking & god bless this website or i'd be jobless!! lol
    Mr MaGoo
    Magoo.Inc MMVII

    If i've helped please add to my Rep by Clicking on the Blue Scales in the top right hand corner of the post

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606
    I'd have thought Range("InsertNameHere") would work, i.e. Range("Lists")

  3. #3
    Valued Forum Contributor Macdave_19's Avatar
    Join Date
    03-14-2007
    Location
    Birmingham, England
    MS-Off Ver
    12.0
    Posts
    808

    Question Help

    Here's the code so far:

    Please Login or Register  to view this content.
    Here's my newest error:

    Unable to get the Vlookup property of the worksheetfunction class
    any ideas?

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    I woulduse the VBA Find method
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    If that's the error then it probably means the lookup is returning N/A.

    How have you populated your combobox?

    What is it you are actually looking up?

  6. #6
    Valued Forum Contributor Macdave_19's Avatar
    Join Date
    03-14-2007
    Location
    Birmingham, England
    MS-Off Ver
    12.0
    Posts
    808

    answer

    To begin with the combobox is empty so it looks up nothing initially, maybe thats the problem? should i place the vlookup in the combobox_change event?

  7. #7
    Valued Forum Contributor Macdave_19's Avatar
    Join Date
    03-14-2007
    Location
    Birmingham, England
    MS-Off Ver
    12.0
    Posts
    808

    Talking Worked

    Thanks for the question you asked, it pointed me in the right direction,

    i placed the lookup in the event change of the combobox and now it works,

    it was obviously failing since the combobox was empty initially!!

    get in!!

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    That isn't really what I'm asking.

    How are you populating the values in the combobox dropdown?

  9. #9
    Valued Forum Contributor Macdave_19's Avatar
    Join Date
    03-14-2007
    Location
    Birmingham, England
    MS-Off Ver
    12.0
    Posts
    808

    sorry bud

    Sorry i got a bit excited heres how i poulated the combobox mate:

    Please Login or Register  to view this content.

  10. #10
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    Well if that's how you've populated the combobox there's no need for either a lookup or find.

    The ListIndex of the combobox will correlate to the row number the data is on.

    FrmGet.TextBox1.Value = Sheets("List").Range("A" & FrmGet.cbAgent.ListIndex+1)

  11. #11
    Valued Forum Contributor Macdave_19's Avatar
    Join Date
    03-14-2007
    Location
    Birmingham, England
    MS-Off Ver
    12.0
    Posts
    808

    Talking

    I have already done it but i will aslo give this method a go!!

    cheers buddy

    much appreciated!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1