Search code examples
google-sheetsgoogle-apps-scriptgoogle-sheets-formulaformula

How to make previous dates data from one tab appear in another tab


I am trying to create a function that pulls data from yesterday's date for "Skin Assessments"(B90:AE93), and "Pt Summary/Caregiver Updates"(B101:101)" from "November2024" tab and puts it into the "Updates" tab as the following:

November2024 tab "Skin Assessment"(B90:AE93)data for yesterdays date going to Updates tab "Yesterday's Skin Assessment"(B17:B20).

November2024 tab "Pt Summary/Caregiver Updates"(B101:101) data for yesterdays date going to Updates tab "Yesterday's Pt Summary/Caregiver Updates"(B12)

Here is the Google Sheets, editor enabled if you want to work it in there.

https://docs.google.com/spreadsheets/d/1adILT_xNvZY8RsbxfKx9hL74TOz-id8gaZKbrlo5C24/edit?usp=sharing


Solution

  • In Updates tab:

    • For B11, use =INDEX(November2024!101:101, MATCH(Updates!B5 - 1, November2024!7:7, 0)).
    • For B17, use =ARRAYFORMULA(INDEX(November2024!90:93, , MATCH(Updates!B5 - 1, November2024!7:7, 0)))

    You should see something like this: enter image description here

    Explanation
    • November2024!B101:101 accesses others November2024's cells for row 101, starting from column B.
    • MATCH(Updates!B5 - 1, November2024!7:7, 0) finds the position of yesterday's date in November2024! row 7.
    • INDEX(November2024!101:101, ...) retrieves the value under that position in the row.
    • ARRAYFORMULA() retrieves the value under multiple rows.

    You can review the Google Sheets function list to learn more.