+ Reply to Thread
Results 1 to 5 of 5

How to populate a table from a database

  1. #1
    Registered User
    Join Date
    09-14-2018
    Location
    Milan, Italy
    MS-Off Ver
    2007
    Posts
    2

    How to populate a table from a database

    Hi there,

    I was trying to populate a table sourcing the data from a database in another sheet but couldn't crack it.
    I attached an example of what i'm trying to achieve: we have weekly orders with an amount of info (sheet 1); i'd like to populate the table in sheet 2 with the "Campaign number" from the sheet 1 (column G) at the intersection of dates and brand number (column D from the Sheet2).
    Getting crazy with INDEX(MATCH()) and others but can't automate the process.
    Thanks a lot
    Renzo
    Attached Files Attached Files

  2. #2
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: How to populate a table from a database

    Hello and welcome to the forum.

    Here's one option:

    E6 =IFERROR(1/(1/SUMIFS('Sheet 1'!$G:$G,'Sheet 1'!$B:$B,E$2,'Sheet 1'!$E:$E,$C6,'Sheet 1'!$F:$F,$D6)),"")

  3. #3
    Registered User
    Join Date
    09-14-2018
    Location
    Milan, Italy
    MS-Off Ver
    2007
    Posts
    2

    Re: How to populate a table from a database

    Man that's just perfect (and straight magic to me)
    Thanks a lot

    R

  4. #4
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: How to populate a table from a database

    You're welcome.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  5. #5
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: How to populate a table from a database

    and straight magic to me
    Let's look at the formula in E6.
    =IFERROR(1/(1/SUMIFS('Sheet 1'!$G:$G,'Sheet 1'!$B:$B,E$2,'Sheet 1'!$E:$E,$C6,'Sheet 1'!$F:$F,$D6)),"")

    Working from the inside out, SUMIFS takes the sum of column G where all of the following conditions are true:
    1) Column B is 10/21/2018
    2) Column E is Bloopies
    3) Column F is 54993

    Since there is only one row where all of these conditions are true, the campaign number for that row is returned.

    If there were no rows where all of these conditions are true, the SUMIFS formula will return 0. This is where IFERROR comes in.

    We can use the fact that 1/x will produce an error only when x=0 to return "" (blank) instead of 0.
    Since we don't want to return, for example, 1/24061995 when the SUMIFS formula returns 24061995, we can use 1/(1/24061995) to return 24061995.

    In other words, if 1/(1/SUMIFS(...)) returns an error, the formula will return "".
    If 1/(1/SUMIFS(...)) does not return an error, the formula will return 1/(1/SUMIFS(...)) which is the same as SUMIFS(...).

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Populate form textbox from database
    By tastefullvenom in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-22-2014, 01:34 AM
  2. Populate table from database with 2 conditions
    By carlo_bruschetti in forum Excel General
    Replies: 3
    Last Post: 01-23-2014, 11:04 PM
  3. Match data between CSV and database and update column in database table
    By djfscouse in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-05-2012, 05:59 PM
  4. Populate Excel report from Database
    By haidermirza in forum Excel General
    Replies: 3
    Last Post: 03-27-2010, 03:40 PM
  5. Auto populate the selection from the database
    By justinng in forum Excel General
    Replies: 5
    Last Post: 01-15-2010, 01:59 PM
  6. Replies: 0
    Last Post: 02-16-2007, 09:12 AM

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