+ Reply to Thread
Results 1 to 10 of 10

Convert text string to lookup array

  1. #1
    Registered User
    Join Date
    06-15-2009
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    5

    Convert text string to lookup array

    Hi,
    I want to be lazy - I've got a budget template that is the same format across several worksheets, but the actual numbers change.

    I want to reference the current budget template just by typing in the name of the worksheet it is in, and a vlookup populates the reconciliation sheet.

    So using ADDRESS(), I can create either side of the array.
    Then with TEXT(), I can turn it into a text "array".
    How can I convert that text "array" and put it into a VLOOKUP() as a search array?

    ie cell C1 is where I have entered "First Budget", which is the name of the corresponding worksheet.
    ADDRESS(5,1,1,1,C1) returns 'First Budget'!$A$5
    ADDRESS(88,8,1,1,C1) returns 'First Budget'!$H$88, which bookends the array

    I've been using TEXT() to combine them and give:
    'First Budget'!$A$5:'First Budget'!$H$88

    What I really want to do is use that as the search array in VLOOKUP, so when the budget changes, I just need to type in the name of the relevant worksheet to update it.

    PS, I know that by definition a budget shouldn't change very often, but believe me, they can and do in my little part of the universe.

  2. #2
    Registered User
    Join Date
    06-15-2009
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Convert text string to lookup array

    Sorry, I just realised I skimmed the forums and posted in the wrong place.

  3. #3
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Convert text string to lookup array

    Hello jmt73,

    I moved this thread to a more appropriate forum (general)

    Try the INDIRECT function....

  4. #4
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Convert text string to lookup array

    heres an example using indirect

    =VLOOKUP(A1,INDIRECT("'"&B1&"'!A1:B20"),2,FALSE)
    sheet name goes in B1
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  5. #5
    Registered User
    Join Date
    06-15-2009
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Convert text string to lookup array

    Thanks, I'll try again.
    I have tried INDIRECT(), but must have been messing something up.

  6. #6
    Registered User
    Join Date
    06-15-2009
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Convert text string to lookup array

    As before, I still get a REF error.
    Could it be the Sheet Name being on both sides of the colon?
    ie 'First Budget'!$A$5:'First Budget'!$H$88
    instead of
    'First Budget'!$A$5:$H$88

  7. #7
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Convert text string to lookup array

    It's not necessary to repeat the sheet name but it should still work if you do. What formula are you using?

  8. #8
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Convert text string to lookup array

    also look carefully at the" and '
    =VLOOKUP(A1,INDIRECT(" ' " &B1&" ' !A1:B20 ") ,2,FALSE)
    Last edited by martindwilson; 06-15-2009 at 08:26 AM.

  9. #9
    Registered User
    Join Date
    06-15-2009
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Convert text string to lookup array

    Quote Originally Posted by daddylonglegs View Post
    It's not necessary to repeat the sheet name but it should still work if you do. What formula are you using?
    cell C1 is where I have entered "First Budget", which is the name of the corresponding worksheet.
    ADDRESS(5,1,1,1,C1) returns 'First Budget'!$A$5
    ADDRESS(88,8,1,1,C1) returns 'First Budget'!$H$88

    I've been using TEXT() to combine them and give:
    =TEXT(ADDRESS(5,1,1,1,TEXT(C1,"")),"")&":"&TEXT(ADDRESS(88,8,1,1,TEXT(C1,"")),"")
    'First Budget'!$A$5:'First Budget'!$H$88

    Then if I chuck it all inside INDIRECT(*,TRUE), I get a REF error.

    Martin's suggestion works where I just hardwire the cell numbers - probably simpler too, which is a good indication...

  10. #10
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Convert text string to lookup array

    i just hate indirect1
    but
    =VLOOKUP(B5,INDIRECT(SUBSTITUTE(CONCATENATE(ADDRESS(5,1,4,1,C1),":",ADDRESS(88,8,4,1,C1)),"'"&C1&"'!","",2)),2,FALSE)
    works

+ 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