Skip to content

Instantly share code, notes, and snippets.

@CHatmaker
Created August 21, 2026 16:23
Show Gist options
  • Select an option

  • Save CHatmaker/80388124ca16ac84cbaef07c0d785c1f to your computer and use it in GitHub Desktop.

Select an option

Save CHatmaker/80388124ca16ac84cbaef07c0d785c1f to your computer and use it in GitHub Desktop.
BXL's Copilot Skill to Add a Debt Schedule
---
name: add-debt-schedule
description: Adds a debt schedule
---
metadata:
version: 1.0.0
tags:
- excel
- lambda
- afe
- excel labs
- named functions
- documentation
- 5g modeling
triggers:
- Add Debt Schedule
- Create Debt Schedule
- Setup Debt Schedule
- Add loan
Rules:
- Namespace-prefix rule:
- When validating workbook-defined functions or named formulas, never require an exact name match.
- Treat a function as available when its name equals the required name or ends with .<required name>
- (for example, Debt.FlexLoanλ, Arrays.SumRCλ, or Dates.Timelineλ).
- Search all workbook names and inspect likely successor functions before reporting anything missing.
- Account for renamed consolidated functions whose parameters provide equivalent behavior.
- Formats rule:
- When adding new worksheets:
- Remove gridlines
- Merge cells A1:G1
- Apply cell style "Title"
- Do not add color, bold, or underlines unless explicitly instructed to do so.
- Apply cell Styles from the style gallery whenever possible.
- References rule:
- Use array references where ever possible
- Functions rule:
- The named functions are known as 5g functions.
- When adding a 5g function to a cell, there should be no other functions in that cell.
- If a 5g function errors and the inputs are correct, that is okay. Do not try to fix by adding formulas.
- Workflow rule:
- Work step-by-step.
- After completing each step, pause and show me the result—including the affected sheet/range and key values—before starting the next step.
- Then continue automatically to the next step.
workflow:
- step 1: Display "SKILL: add-debt-schedule VERSION: BXL 2026-08-20"
- step 2: Gather Information
actions:
- Do these things in order. Wait for responses from Ask: before asking next question.
- If a named range "Language" does not exist:
- Ask: "Which language would you prefer to use?" in the regional setting's likely language.
- Display options as a numbered list:
1 English
2 Español
3 Français
4 Deutsch
5 Italiano
6 Português
7 中文
8 日本語
9 한국어
10 Other — type the language you want to use.
- Switch to the language and use it for the remaining steps and worksheet entries.
- Display: "This requires the following 5g libraries: Array Essentials, Dates, and Debt."
- Display: "If you need help getting these libraries, see this tutorial: https://youtu.be/WAvXJ2aljOw "
- Ask: "When these libraries are loaded type C and press ENTER to continue."
- If a workbook-level named range named “Currency” does not exist (case-insensitive),
- Ask: “What is the primary currency?” Enumerate USD, EUR, JPY, GBP, AUD, CAD, CHF, CNY, other?
- Otherwise, use its value and do not ask.
- If a workbook-level named range named “MonetaryFormat” or “Monetary_Format” does not exist (case-insensitive),
- Ask: "Select monetary cell style/number format:" Enumerate Comma, Comma [0], Currency, Currency [0], or Custom.
- Otherwise, use its value and do not ask.
- If a workbook-level named range named “DateFormat” or "Date_Format" does not exist (case-insensitive),
- Ask: "Select date cell style/number format:" Enumerate standard date formats or Custom (e.g., dd-mmm-yy).
- Otherwise, use its value and do not ask.
- step: 3
name: Setup
actions:
- Do these things in order.
- Ask: "Which worksheet shall I add the debt schedule to?" then enumerate all worksheet names. Add to the list, "or enter name of new worksheet"
- If requested to create a new worksheet:
- Merge cells A1:G1.
- Add "Debt Schedule" to cell A1.
- Apply cell style Title to A1.
- Remove gridlines
- Copy worksheet Time's timeline rows starting from A3 to the new worksheet.
- Display the selected worksheet (or new worksheet if you created it).
- Remember the first occupied column below row 2 as the label column.
- Remember the column with the timeline's first numeric date as the calcs column.
- step: 4
name: Add input links
actions:
- Ask: "Select the loan to add" then enumerate all loan names from tblLoans[Loan].
- Find the last occupied row. Move 1 row down.
- In the label column add "Loan" and next to it add the loan name.
- In the row below:
- Add "Loan Type"
- Next to it add function GetFieldλ to retrieve the Loan Type from tblLoans.
- Do not use IFNA, IFERROR or any other function with GetFieldλ. If it causes errors, that is okay.
- In the row below:
- Add function InputLabelsλ, which may have a registerd name prefix, to add input labels
- Next to each Input label apply the function GetFieldλ to each input label.
- Use your intelligence to determine what table the field comes from and the field name.
- If Style Gallery style "Input From" exists, apply it to the input results and their spill range.
- step: 5
name: Add DCC display
actions
- Find the next unoccupied row.
- In the calcs column add function DCCDisplayλ and link to the loan's linked inputs on this worksheet.
- NOTE! If the loan type is PIK, get APRs from PIK APRs and APR dates from PIK Dates.
- In the labels column add: Month Days; Year Days; APRs; and MIRs. Left align.
- Apply the monetary cell style to monthy days values and year days values.
- Apply the percent cell style to APRs values and MIRs values.
- Move 1 row down.
- step: 6
name: Add debt function
actions:
- In the calcs column add the appropriate debt function for this loan's loan type and link the inputs.
- Apply the monetary cell style to monetary values and the percent cell style to percentages.
- Apply the Subtotal cell style to the Ending debt balance values.
- In the same row as the debt function and in the labels column, add DebtLabelsλ.
- step: 7
name: Add row totals
actions:
- In the column left of the debt schedule and one row above, add the word "Totals" and right align.
- In the column left of the debt schedule, add function SumRCλ() to charges, payments, and draws, NOT balances or percentages.
- NOTE! SumRCλ() is position aware and will total the row it is place in so link it to the debt schedule array's anchor cell.
- Apply the monetary cell style to these totals and no other style.
- step: 8
name: Format
actions:
- Apply selected cell styles and number formats appropriately.
- Select all cells then autofit all columns
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment