+ Reply to Thread
Results 1 to 9 of 9

Referencing multiple tables

  1. #1
    Registered User
    Join Date
    10-06-2017
    Location
    US
    MS-Off Ver
    2013
    Posts
    5

    Referencing multiple tables

    I'm trying to get a calendar output for employees and their attendance.

    I have a worksheet with all the employee info, but the relevant info for the calendar is their Employee ID. I have a cell that already uses that as a dropdown menu on the worksheet that I want to show the calendar with their attendance. There's also a cell that selects the month from a dropdown menu. The Calendar output already pulls up a calendar based on the month and year entered on the worksheet (though I had to use someone else's tables to calendar to come out with a desirable layout).

    There's a worksheet for each month that has every employee listed, and then has a row for the entire month laid out next to them, with inputs for 4 possibilities for attendance. I want the calendar to be able to pull up each employees monthly attendance, and then display it in a calendar format instead of the vertical row format the information gets placed into.

    I understand how to reference the entire table, but not how to sort through the referenced table for the desired information and then to display in the desired format.

    I've spent the better part of a week learning excel functions and terminology, and I'm still making sense of the more complicated aspects, like how pivot tables function, so you may need to explain in laymen's terms for me.

    I imagine this can be similar to a question someone else has already asked on here, but with a specific set of parameters, I can't imagine using a search functioning paying off with a relevant thread. But since I'm betting someone has already asked the essence of my question, links to a thread with an answer are more than appreciated in lieu of a fully written out explanation.

    Thank you for reading my question and any possible subsequent help.

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Referencing multiple tables

    It sounds like you have the data in almost the right format. However, to take it further, we'd need to see a sample workbook.

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Registered User
    Join Date
    10-06-2017
    Location
    US
    MS-Off Ver
    2013
    Posts
    5

    Post Re: Referencing multiple tables

    Here's the workbook. The data entered into the monthly worksheets would be the manual work, I'm just not sure how to get the table on the output sheet to reference those tables while also sorting for the specified employee.

    I tried to use a flow chart on piece of paper to help me come up with an idea of how it would work, but that wasn't much help. Ideally, I'd like it to fill in with the S or V that would be entered for the specific dates of that month.

    The other problem I think may come up is the layout for each month. I believe I've tested them to see if they work correctly for each month that can be selected. I tweaked someone else's calendar formatting, so if there are any changes that need to be made to that, it may go over my head.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    10-06-2017
    Location
    US
    MS-Off Ver
    2013
    Posts
    5

    Post Re: Referencing multiple tables

    Sorry, this file has the added worksheet that shows how I'd like the data to show up for an individual with the selected month and employee ID
    Attached Files Attached Files

  5. #5
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Referencing multiple tables

    This was not too bad. You had the data well-organized and that's always a good start.

    I had to modify the calendar a bit. I noticed that when I changed months, it broke and I could not get May to come back. However, it was a minor fix. I unhid all the rows and columns on the calendar. So I could see what went on "under the hood." I left them unhidden so you can see what's going on too. For cosmetic purposes you can hide what you do not want to see.

    I added an extra formula in cell F4 - I needed the person's name, so I did a VLOOKUP against the employee list.

    Since we are dealing with the same formulas applied to multiple sheets, I made extensive use of INDIRECT. One such formula is in Cell Q4: =MATCH(F4,INDIRECT($Q$7&"!B:B"),0) - This finds where the the person's name appears on the monthly sheet.

    Since we are using INDIRECT, the monthly names in Cell A5 must match the tab names, so I have a helper cell in Q7 to truncate the full month name as displayed on the calendar to match the tabs.

    The main "meat" of the formula is =IFERROR(OFFSET(INDIRECT($Q$7&"!$A$1"),$Q$4-1,MATCH(A9,INDIRECT($Q$7&"!9:9"),0)-1,1,1),"") What this formula essentially says is go to Cell A1 on the monthly sheet, Go down to the row containing the person's name, find the column associated with the date in row 9. Give me the result of the intersection.

    There is a slight issue with this formula: if the intersection is blank, for some reason the formula returns zero instead of blank. There are a couple of ways to handle this. The one I opted for was to move the formulas "off to the side" in columns S:AE. Then I could use the relatively simple formula: =IF(S10<>0,S10,"") to fill in the calendar.
    Attached Files Attached Files

  6. #6
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Referencing multiple tables

    P.S. Is there a reason you have this in pre-2007 format (XLS)? If you save it as XLSX, you could use Excel tables.

    One of the advantages of Excel Tables is that they "self extend" meaning that when you add a row at the bottom or a column to the right, they become part of the table. This means that tables know how big they are, so any charts, pivot tables or formulas that reference them do not need to be changed when data is added or deleted from the table. So you don't have to do something like =SUM(B:B) to look at more than a million rows or =SUM(B2:B100) and hope that the data doesn't go beyond row 100. Instead you can use something like =SUM(Table_Data[Column_Name]) and Excel knows exactly how many rows are in Column_Name.

    Another advantage of tables is that the copy down formulas, formats and validations automatically as rows are added. No need to "pad" them manually.

    This might come in handy on the Monthly Sheets and on the Employee Sheets. If you are adding and deleting a lot of employees, the formula you now have in column K can get cumbersome to maintain. You could probably come up with a formula to find the employee in the various tables and do the summation.

    Here is something to get you started on Tables: http://www.utteraccess.com/wiki/Tables_in_Excel.

  7. #7
    Registered User
    Join Date
    10-06-2017
    Location
    US
    MS-Off Ver
    2013
    Posts
    5

    Thumbs up Re: Referencing multiple tables

    Well that's pretty incredible. I understand the concepts behind the formulas, but the actual implementation eludes me. Your formulas reference the tables in the tabs by searching for the employee, then load the data into a table format which is then translated into the view format I'm looking for, basically.

    The INDIRECT function still kind of went over my head. How does that one work? And I've never seen that IFERROR one. Can you break that down into the pieces you used?

    I didn't catch the file being in the older format. I pulled from a few sources to get the entirety of the workbook, so most likely that's why it's in an old format. I've updated it, since the functionality of the tables you talked about will definitely come in handy as we get new employees that need to be added.

    I'll spend some time reading that link you shared and see if that helps me understand this a bit more. I've been doing more reading off and on as time allows, so thanks for giving me a direction. And thanks for your help, that was EXACTLY what I was looking to get from the data, but I had no idea how to sort through it like that.

  8. #8
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Referencing multiple tables

    Indirect takes a string that looks like it should be a range and converts it into an actual range. So if Cell B1 contains the name of a month, for example May then "'"&B1&"'!A:A" translates to 'May'!A:A. So I can do something like =SUM("'"&B1&"'!A:A") and I will get the sum in column A on the sheet whose month is in cell B1. INDIRECT was invented pretty much for this reason (switching sheet named dynamically).

    IFERROR has the syntax of IF(This expression has an error, Return this value) - otherwise, it just evaluates the expression.

    Prior to Excel 2007, "escaping" an error took a lot more work. For example, if you were trying to do =VLOOKUP(A2,Some_Range,2,False) and the value in A2 isn't in Some_Range, you get a #N/A error. If you did not want to show the error then you would have to write:
    =IF(ISNA(VLOOKUP(A2,Some_Range,2,False)), "",VLOOKUP(A2,Some_Range,2,False)) Which not only is a long formula, but it also means Excel had to compute the VLOOKUP and then determine if it evaluated to #N/A and if it didn't compute the VLOOKUP again.

    =IFERROR(VLOOKUP(A2,Some_Range,2,False),"") might do the same thing behind the scenes, but it's a lot less typing. However it will return the null string on any error such as #VALUE (which is what I think you get if you try to reference a column beyond the range).

    Similarly, you used to have to check the denominator in a division =IF(B2<>0,A2/B2,0) - now you can use IFERROR(A2/B2,0).

    Finding a value in a range is what MATCH is for. =Match(This value, in this range, flag). If the flag is zero, match looks for an exact match and returns where, in the range of values the value is found (usually the row or column number) - or #N/A if not found.

    With a flag of -1 it looks for the value and if it can't find it, it goes to the next lowest value. With a flag of +1 it looks for the value and if it can't find it, it goes to the next highest value. However, in both cases, the data has to be sorted by what you are searching on.

    The only other trick I used was OFFSET, and this I do have documented: http://www.utteraccess.com/wiki/Offs...Dynamic_Ranges - I probably could have also used INDEX instead. The two commands are closely related.

    The discussion on Tables was a suggested improvement. Tables are not involved with the solution at all.

  9. #9
    Registered User
    Join Date
    10-06-2017
    Location
    US
    MS-Off Ver
    2013
    Posts
    5

    Re: Referencing multiple tables

    That all seems a little useful. Thanks for the information! I'll have to remember this stuff if I ever need to make more tables.

+ 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. Multiple referencing from different imported tables - melting my brain!
    By MoscowMike in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 05-27-2014, 12:54 PM
  2. Structured Referencing tables
    By Tom_J_W in forum Excel General
    Replies: 8
    Last Post: 06-17-2013, 03:03 AM
  3. Referencing names to search tables
    By Kram222 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-12-2012, 10:28 PM
  4. Excel 2007 : Cross Referencing tables
    By TheAesthete in forum Excel General
    Replies: 4
    Last Post: 03-09-2011, 07:15 AM
  5. Referencing data from pivot tables
    By Dan27 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-14-2010, 01:36 PM
  6. Referencing to tables
    By The Guy in forum Excel General
    Replies: 2
    Last Post: 03-05-2009, 04:13 AM
  7. referencing two tables
    By spog00 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-05-2005, 07:57 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