+ Reply to Thread
Results 1 to 6 of 6

Populate asyncronous data

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    12-02-2008
    Location
    Brisbane
    MS-Off Ver
    2016
    Posts
    811

    Populate asyncronous data

    I'm trying to work out a method (formula if possible, otherwise VBA if not) to populate date from one table to another where the data is not in similar table formats. Sample attached for any ideas.

    Thanks
    Attached Files Attached Files
    Last edited by BRISBANEBOB; 04-01-2009 at 02:13 AM.

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,053

    Re: Populate asyncronous data

    Try:

    =SUMPRODUCT(--(Sheet2!$A$6:$A$18=Sheet1!$A5);--(Sheet2!$B$6:$B$18=B$4);Sheet2!$C$6:$C$18)
    Never use Merged Cells in Excel

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Populate asyncronous data

    I would add a lookup key in column D to the data itself then use a simple INDEX/MATCH. Without the key you would probably need an array formula or SUMPRODUCT, both of which slow your sheet performance in large numbers.

    =IF(ISERROR(MATCH($A5&B$4,Sheet2!$D$6:$D$18,0)),"",INDEX(Sheet2!$C$6:$C$18,MATCH($A5&B$4,Sheet2!$D$6:$D$18,0)))

    If you install the IFERROR UDF into your sheet, you can even simplify further:
    =IFERROR(INDEX(Sheet2!$C$6:$C$18,MATCH($A5&B$4,Sheet2!$D$6:$D$18,0)),"")

    IFERROR UDF code:
    Function IFERROR(ToEvaluate As Variant, Default As Variant) As Variant
        If IsArray(ToEvaluate) Then
            IFERROR = IIf(IsError(ToEvaluate(1)), Default, ToEvaluate)
        Else
            IFERROR = IIf(IsError(ToEvaluate), Default, ToEvaluate)
        End If
    End Function
    Even without the UDF, INDEX/MATCH is fast fast for this kind of stuff, even in large numbers.
    Attached Files Attached Files
    Last edited by JBeaucaire; 04-01-2009 at 02:03 AM.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  4. #4
    Forum Contributor
    Join Date
    12-02-2008
    Location
    Brisbane
    MS-Off Ver
    2016
    Posts
    811

    Re: Populate asyncronous data

    Both solutions work a treat - thanks.

    With the =SUMPRODUCT solution I replaced the ";" with a comma to get it to work. Why do we use a comma? What does it do? WHy not an * ?

    With the INDEX/MATCH solution, what is the IFERROR UDF? I assume UDF is User Defined Code??

    Thansk for the help.

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Populate asyncronous data

    The INDEX/MATCH will return an error if the MATCH value isn't found. To test for that, you have to verify the MATCH is going to work before you use it. IF(ISERROR() does that, but if it passes the test, you have to do the formula again to get the actual answer.

    Honestly, even doing a double evaluation like that, it's still less plumbing on your sheet than array formulas or tons of SUMPRODUCT which are only marginally better, IMO.

    In Excel 2007 they solved that by offering you the IFERROR option. IFERROR let's you just run the formula once...if it works you get the normal answer, but if an error occurs, it stifles the error and returns your default value instead, or lets you even run a different formula...up to you.

    =IFERROR(YourFormula,DoThisOnError)

    To install the IFERROR code into earlier versions of Excel:

    Press ALT-F11 to open the VBEditor
    Click Insert > Module
    Paste in the code
    Alt-F11 to close the editor
    Save your sheet.

    Now you can use that function as shown.

    Your sample sheet indicates a LOT of cells. I encourage you to consider all your alternatives based on warnings already given.

  6. #6
    Forum Contributor
    Join Date
    12-02-2008
    Location
    Brisbane
    MS-Off Ver
    2016
    Posts
    811

    Re: Populate asyncronous data

    Thanks for that explanation - the learning process continues!

+ 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