How to Make Volunteer Hours Verification Letters from Google Sheets: One PDF per Request, with Dates and Totals (2026)

Sooner or later every volunteer program gets the same email: “Can you send a letter confirming my hours?” A student needs it for a graduation or honor-society requirement, someone else for a scholarship, a job application or a court-ordered community service condition, and each one wants a different date range, sent to a different place, often by Friday. If your hours live in a Google Sheet, the answer shouldn't be an afternoon of filtering rows and retyping totals into a letter. This guide sets up an Hours tab (one row per volunteer per day served), a Requests tab (one row per letter someone asks for), formulas that show each person's verified hours as you type, and a free Apps Script that makes one PDF letter per request: the total for exactly the dates asked for, what they did, a dated list of every day served and a signature block, with the link written back to the request.

How this differs from the other volunteer and certificate guides here: the volunteer shift guide fills shifts and reminds people before they come (its Signups tab can feed this script directly, see Step 5). Training certificates confirm a course was completed. A verification letter is different: it adds up many separate days of service for one person and one period, and someone at your organization signs it as a true record.

What schools, courts and programs look for

Requirements vary, so the first rule is: ask the volunteer whether the school, court or program has its own form. Many do, and some accept only theirs; your letter can then go with it as the supporting record. Where a letter on your letterhead is accepted, the details checked are nearly always the same: the volunteer's name, your organization's name and contact details, the dates of service, the total hours, a short description of the work, and the name, title, contact details and signature of the person who can vouch for it, plus the date of the letter.

Federal probation is a good example of why a dated log matters. The US Courts' guidance on the community service condition has the person provide written verification of completed hours to the probation officer, says the site should have a reliable manager who will give accurate information about attendance and participation, and notes that hours may be checked by contacting the service agency or reviewing its documentation. Some probation offices also use their own time sheet that the site supervisor dates and signs for each day worked (the District of Nevada's instructions are one example). That is why the letter below lists every day with its hours, and why the script only counts hours someone has marked as verified.

This guide is about producing an accurate record, not legal advice. Only sign for hours your organization can stand behind.

Step 1: an Hours tab, one row per volunteer per day

Name the tab Hours. The script finds columns by their header, so the order is up to you, and only Date, Volunteer and Hours are required; the formulas below assume this layout:

ColHeaderWhat goes in it
ADateThe day served, formatted as a date (Format › Number › Date). Text that only looks like a date won't work.
BVolunteer IDOptional: a stable code like V-0042. Rows with the same ID are one person even if the name was typed differently. Without IDs, rows are matched by Email, then by name, ignoring capitals and extra spaces.
CVolunteerThe person's full name, as it should appear on the letter (schools and courts match it against their records, so use the legal name, not a nickname)
DEmailOptional
EActivityWhat they did, in words someone outside your organization understands: “Sorting donated food”, “Reading tutor, grades 2–3”, not “Helper”. Blank prints as “Volunteer service”.
FSupervisorOptional: who was in charge that day. Printed in the dated list when filled in.
GHoursA number such as 2.5 (at most 24 per row). For start and end times, see below.
HVerifiedA checkbox (Insert › Checkbox) or the supervisor's initials. Only verified rows go on a letter. Blank, “No” or “Pending” means not yet.

One row per person per day (or per shift, if they did two different things in a day) is what lets the letter list dates and lets you answer “which days?” months later. Ask whoever runs each session to tick Verified the same day, while they still remember who was there; checking off a month of rows at once is exactly what makes a record hard to vouch for. If you keep a paper sign-in sheet at the door, type it in weekly and keep the paper.

If you record start and end times instead, add Start and End columns (I and J, formatted as times) and put this in G2, filled down. It rounds to the nearest quarter hour and handles sessions that run past midnight:

=IF(OR(I2="", J2=""), "", ROUND(MOD(J2-I2, 1)*24*4, 0)/4)

If your program doesn't count breaks, travel or training toward service hours, leave them out of the times. Whatever you decide, apply it the same way for everyone and say so if asked.

Step 2: a Requests tab, one row per letter

Add a tab named Requests. Each time someone asks for a letter, add a row:

ColHeaderWhat goes in it
AVolunteerTheir name, as on the Hours tab
BVolunteer IDOptional; if both tabs have IDs, the ID is what matches
CEmailOptional: matches the Hours tab's Email when both are filled in, and is where the PDF goes if you turn emailing on
DAddressed toOptional: “Counseling office, Central High School”. Blank prints “To whom it may concern”.
EPurposeOptional: completes the sentence “...on 12 separate days, for the school's service-hour requirement.” Keep it general; the letter doesn't need case numbers or why someone was asked to serve.
F, GFrom, ToThe period the letter covers, as dates. Blank From means from their first day; blank To means up to today.
HRequired hoursOptional: the target they have to meet. The letter then says “This meets the 40 hours required” or how many remain.
IVerified hours so farFormula (Step 3); the script ignores it

The script adds three columns of its own the first time it runs, Letter (the PDF link), Hours on letter and Made at, and skips any request whose Letter cell is filled in. To make a corrected letter, clear that cell and run it again; the new PDF replaces the old one in the folder.

Step 3: verified hours as you type, and checks before you sign

In Requests!I2, filled down, the verified hours for that person and period, using the same rules as the script (name match only; use the ID columns instead of A and C if you have them):

=IF(A2="", "", SUMIFS(Hours!$G:$G, Hours!$C:$C, A2, Hours!$H:$H, TRUE,
  Hours!$A:$A, ">=" & IF(F2="", DATE(1900,1,1), F2),
  Hours!$A:$A, "<=" & IF(G2="", TODAY(), G2)))

SUMIFS only adds a row when every condition matches, which is what you want here: right person, verified, inside the dates. This version counts only ticked checkboxes; if you use initials in Verified, replace TRUE with "<>" (counts any non-blank cell, so write “Pending” only if you also exclude it). Compare I with the Required hours before you promise anyone a letter.

Three rules on the Hours tab (select A2:H, Format › Conditional formatting › Custom formula is) catch the usual problems:

Custom formulaColorMeaning
=AND($A2<>"", $A2<TODAY()-7, $H2<>TRUE)AmberServed over a week ago and still not verified (use $H2="" if you use initials)
=AND($C2<>"", COUNTIFS($A:$A, $A2, $C:$C, $C2, $E:$E, $E2, $G:$G, $G2)>1)RedSame person, day, activity and hours twice: probably typed in twice
=AND($A2<>"", OR(N($G2)<=0, N($G2)>24))RedHours missing or impossible

The script reports the same things by row number when it runs, so nothing doubtful goes on a letter without you seeing it first.

Step 4: the script (one PDF letter per request)

Create a Drive folder for the letters and copy its ID (the part of the folder's URL after /folders/). Open Extensions › Apps Script, paste the script below, and set FOLDER_ID, ORG_NAME, ORG_LINES (address, phone and email; they print as the letterhead), SIGNER_NAME, SIGNER_TITLE and SIGNER_CONTACT. Add ORG_EIN if the schools or courts you deal with ask for your tax ID. Then:

  1. Reload the spreadsheet and run Volunteer hours › Make verification letters, approving the permissions the first time. PREVIEW is true, so it makes at most 3 PDFs named “PREVIEW ...”, emails nobody and writes nothing back.
  2. Open the previews and check them against the sheet: name, dates, total, activities. Delete them when you're happy.
  3. Set PREVIEW = false, save and run it again. It makes one PDF per open request and fills in Letter, Hours on letter and Made at. If there are more than MAX_PER_RUN (25), run it again; finished requests are skipped.
// Volunteer hours verification letters from a Google Sheets hours log: one PDF letter per request,
// with the volunteer's verified hours for the dates asked for, what they did, a dated log of each
// day served and a signature block for the person who supervised them.
// Sheet: an Hours tab (Date, Volunteer or Name, Hours, plus optional Volunteer ID, Email, Activity
// or Role, Supervisor, Verified, Status) and a Requests tab, one row per letter asked for
// (Volunteer or Name, plus optional Volunteer ID, Email, Addressed to, Purpose, From, To,
// Required hours). The script only reads the Hours tab. On the Requests tab it fills in three
// columns of its own: Letter, Hours on letter and Made at.
const FOLDER_ID = 'PASTE_DRIVE_FOLDER_ID';    // Drive folder for the PDFs
const HOURS_SHEET = 'Hours';                    // or 'Signups' if you use the volunteer shift guide
const REQUESTS_SHEET = 'Requests';
const ORG_NAME = 'Your organization name';
const ORG_LINES = ['Street address', 'City, State ZIP', 'Phone', 'volunteer@yourorg.example'];  // printed under the name
const ORG_EIN = '';                             // optional, e.g. '12-3456789'; some schools and courts ask
const SIGNER_NAME = 'Name';                     // the person who signs: someone who can vouch for the hours
const SIGNER_TITLE = 'Volunteer Coordinator';
const SIGNER_CONTACT = 'Phone or email for verification';
const LIST_EACH_DAY = true;                     // true = a dated table of every day served
const COUNTED_STATUSES = ['attended', 'completed', 'verified', 'approved', 'done', 'yes'];
const EMAIL_LETTERS = false;                    // true = email each PDF to the request's Email
const PREVIEW = true;                           // true = at most 3 PDFs named "PREVIEW ...", emails only to you, nothing written back
const REPLY_TO = '';                            // optional reply-to address for emails
const MAX_PER_RUN = 25;                         // run again to continue; finished requests are skipped
const MAX_MINUTES = 4.5;                        // stop before Apps Script's 6-minute limit
const KEEP_DOCS = false;                        // false = keep only the PDF, not the Google Doc
const DAY = 86400000;
const MONTHS = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September',
  'October', 'November', 'December'];

function onOpen() {
  SpreadsheetApp.getUi().createMenu('Volunteer hours')
    .addItem('Make verification letters', 'makeHoursLetters')
    .addToUi();
}

function makeHoursLetters(now) {
  let ui = null;
  if (!(now instanceof Date)) {          // run from the menu or a trigger
    now = new Date();
    try { ui = SpreadsheetApp.getUi(); } catch (e) { ui = null; }   // no UI when a trigger runs it
  }
  const lock = LockService.getDocumentLock();
  if (!lock.tryLock(30000)) return;      // another run is still busy
  try {
    const result = run_(now, Date.now());
    if (ui) ui.alert(summary_(result));
    return result;
  } finally {
    lock.releaseLock();
  }
}

function run_(now, startedMs) {
  const ss = SpreadsheetApp.getActive();
  const tz = ss.getSpreadsheetTimeZone();
  const today = dayNum_(Utilities.formatDate(now, tz, 'yyyy-MM-dd'));
  const hoursSheet = ss.getSheetByName(HOURS_SHEET);
  if (!hoursSheet) throw new Error('No tab named ' + HOURS_SHEET + '.');
  const reqSheet = ss.getSheetByName(REQUESTS_SHEET);
  if (!reqSheet) throw new Error('No tab named ' + REQUESTS_SHEET + '.');
  const log = readHours_(hoursSheet.getDataRange().getValues(), tz, today);
  const reqValues = reqSheet.getDataRange().getValues();
  const req = readRequests_(reqValues, tz);
  const res = { preview: PREVIEW, made: 0, emailed: 0, alreadyDone: 0, left: 0, quota: false, timeUp: false,
    noHours: [], short: [], notCounted: [], noEmail: [], skippedRows: log.skipped, badRequests: req.skipped,
    duplicates: log.duplicates, pdfs: [] };
  const todo = req.list.filter(function (r) {
    if (!PREVIEW && r.done) { res.alreadyDone++; return false; }
    return true;
  });
  if (!todo.length) return res;
  let cols = null;                       // Letter / Hours on letter / Made at, added if missing
  const folder = DriveApp.getFolderById(FOLDER_ID);
  const me = Session.getEffectiveUser().getEmail();
  const limit = PREVIEW ? Math.min(3, MAX_PER_RUN) : MAX_PER_RUN;
  for (let i = 0; i < todo.length; i++) {
    const r = todo[i];
    if (res.made >= limit) { res.left = todo.length - i; break; }
    if (Date.now() - startedMs > MAX_MINUTES * 60000) { res.left = todo.length - i; res.timeUp = true; break; }
    const v = collect_(r, log.rows, today);
    if (v.notCounted) res.notCounted.push(r.name + ': ' + hrs_(v.notCounted) + ' hours not verified, left out');
    if (!v.days.length) { res.noHours.push(r.name + ' (Requests row ' + r.row + ')'); continue; }
    if (r.required && v.total < r.required * 100) res.short.push(r.name + ': ' + hrs_(v.total) + ' of ' + hrs_(r.required * 100) + ' hours');
    const emails = EMAIL_LETTERS ? emails_(r.email) : null;
    const to = emails ? (PREVIEW ? [me] : emails) : [];
    if (to.length && MailApp.getRemainingDailyQuota() < to.length) {
      res.left = todo.length - i; res.quota = true; break;     // tomorrow's run continues here
    }
    const made = makePdf_(folder, r, v, today, PREVIEW ? 'PREVIEW ' : '');
    res.made++;
    res.pdfs.push(made.url);
    if (EMAIL_LETTERS && !emails) res.noEmail.push(r.name);
    if (to.length) {
      MailApp.sendEmail(mail_(r, v, made.blob, to, emails));
      res.emailed++;
    }
    if (!PREVIEW) {
      if (!cols) cols = outputColumns_(reqSheet, reqValues[0]);
      reqSheet.getRange(r.row, cols.letter + 1).setValue(made.url);
      reqSheet.getRange(r.row, cols.hours + 1).setValue(v.total / 100);
      reqSheet.getRange(r.row, cols.madeAt + 1).setValue(Utilities.formatDate(now, tz, 'yyyy-MM-dd HH:mm') +
        (to.length ? ', emailed to ' + emails.join(', ') : ''));
      SpreadsheetApp.flush();             // the link survives even if a later letter fails
    }
  }
  return res;
}

function readHours_(values, tz, today) {
  const col = finder_(values[0]);
  const c = { date: col('Date'), name: either_(col, 'Volunteer', 'Name'), id: col('Volunteer ID'), email: col('Email'),
    hours: col('Hours'), activity: either_(col, 'Activity', 'Role'), sup: col('Supervisor'),
    verified: col('Verified'), status: col('Status') };
  if (c.date < 0 || c.name < 0 || c.hours < 0) {
    throw new Error('The ' + HOURS_SHEET + ' tab needs Date, Volunteer (or Name) and Hours columns in its first row.');
  }
  const rows = [], skipped = [], seen = {}, duplicates = [];
  for (let i = 1; i < values.length; i++) {
    const v = values[i], n = i + 1;
    const get = function (k) { return c[k] < 0 || v[c[k]] == null ? '' : v[c[k]]; };
    const name = String(get('name')).trim();
    if (!name && String(get('hours')).trim() === '' && String(get('date')).trim() === '') continue;   // empty row
    const day = toDay_(get('date'), tz);
    if (day === null) { skipped.push('Hours row ' + n + ': Date is not a date'); continue; }
    if (!name) { skipped.push('Hours row ' + n + ': no volunteer name'); continue; }
    const h = number_(get('hours'));
    if (isNaN(h)) { skipped.push('Hours row ' + n + ': Hours is not a number'); continue; }
    if (h <= 0 || h > 24) { skipped.push('Hours row ' + n + ': Hours must be more than 0 and at most 24'); continue; }
    if (day > today) continue;            // a future shift: not served yet
    const status = String(get('status')).trim().toLowerCase();
    const ver = get('verified');
    const verText = String(ver).trim().toLowerCase();
    const counted = (c.status < 0 || COUNTED_STATUSES.indexOf(status) >= 0) &&
      (c.verified < 0 || ver === true || (verText !== '' && ['no', 'n', 'false', 'pending', '0'].indexOf(verText) < 0));
    const row = { row: n, day: day, name: name, key: norm_(name), id: norm_(get('id')), email: String(get('email')).trim().toLowerCase(),
      cents: Math.round(h * 100), activity: String(get('activity')).trim(), sup: String(get('sup')).trim(), counted: counted };
    if (counted) {
      const k = [row.id || row.key, day, row.cents, row.activity.toLowerCase()].join('|');
      if (seen[k]) duplicates.push('Hours rows ' + seen[k] + ' and ' + n + ': same volunteer, date, hours and activity');
      else seen[k] = n;
    }
    rows.push(row);
  }
  return { rows: rows, skipped: skipped, duplicates: duplicates };
}

function readRequests_(values, tz) {
  const col = finder_(values[0]);
  const c = { name: either_(col, 'Volunteer', 'Name'), id: col('Volunteer ID'), email: col('Email'), to: col('Addressed to'),
    purpose: col('Purpose'), from: col('From'), until: col('To'), required: col('Required hours'), letter: col('Letter') };
  if (c.name < 0 && c.id < 0) throw new Error('The ' + REQUESTS_SHEET + ' tab needs a Volunteer (or Name) or Volunteer ID column.');
  const list = [], skipped = [];
  for (let i = 1; i < values.length; i++) {
    const v = values[i], n = i + 1;
    const get = function (k) { return c[k] < 0 || v[c[k]] == null ? '' : v[c[k]]; };
    const name = String(get('name')).trim(), id = String(get('id')).trim();
    if (!name && !id) continue;
    const fromSet = String(get('from')).trim() !== '', untilSet = String(get('until')).trim() !== '';
    const from = fromSet ? toDay_(get('from'), tz) : null;   // blank From = from the first day served
    const until = untilSet ? toDay_(get('until'), tz) : null; // blank To = up to today
    if ((fromSet && from === null) || (untilSet && until === null)) { skipped.push('Requests row ' + n + ': From or To is not a date'); continue; }
    if (from !== null && until !== null && from > until) { skipped.push('Requests row ' + n + ': From is after To'); continue; }
    const reqText = String(get('required')).trim();
    const required = reqText === '' ? 0 : number_(reqText);
    if (isNaN(required) || required < 0) { skipped.push('Requests row ' + n + ': Required hours is not a number'); continue; }
    list.push({ row: n, name: name || id, key: norm_(name), id: norm_(id), email: String(get('email')).trim(),
      addressedTo: String(get('to')).trim(), purpose: String(get('purpose')).trim(), from: from, until: until,
      required: required, done: String(get('letter')).trim() !== '' });
  }
  return { list: list, skipped: skipped };
}

// The hours that belong on one letter: same volunteer, inside the dates asked for, counted rows only.
function collect_(r, rows, today) {
  const email = r.email.toLowerCase();
  const mine = rows.filter(function (x) {
    if (r.id && x.id) return r.id === x.id;
    if (email && x.email) return email === x.email;
    return r.key !== '' && r.key === x.key;
  }).filter(function (x) {
    return (r.from === null || x.day >= r.from) && (r.until === null || x.day <= r.until);
  });
  const days = mine.filter(function (x) { return x.counted; })
    .sort(function (a, b) { return a.day - b.day || a.row - b.row; });
  const total = days.reduce(function (s, x) { return s + x.cents; }, 0);
  const notCounted = mine.filter(function (x) { return !x.counted; }).reduce(function (s, x) { return s + x.cents; }, 0);
  const acts = {}, order = [];
  days.forEach(function (x) {
    const a = x.activity || 'Volunteer service';
    if (!(a.toLowerCase() in acts)) { acts[a.toLowerCase()] = { name: a, cents: 0 }; order.push(a.toLowerCase()); }
    acts[a.toLowerCase()].cents += x.cents;
  });
  const dates = {};
  days.forEach(function (x) { dates[x.day] = true; });
  return { days: days, total: total, notCounted: notCounted, dayCount: Object.keys(dates).length,
    first: days.length ? days[0].day : null, last: days.length ? days[days.length - 1].day : null,
    activities: order.map(function (k) { return acts[k]; }).sort(function (a, b) { return b.cents - a.cents; }),
    name: r.name, today: today };
}

function outputColumns_(sheet, header) {
  const h = (header || []).map(function (x) { return String(x).trim().toLowerCase(); });
  let width = h.length;
  while (width > 0 && h[width - 1] === '') width--;
  const out = {};
  [['letter', 'Letter'], ['hours', 'Hours on letter'], ['madeAt', 'Made at']].forEach(function (p) {
    let i = h.indexOf(p[1].toLowerCase());
    if (i < 0) { i = width++; sheet.getRange(1, i + 1).setValue(p[1]); }
    out[p[0]] = i;
  });
  return out;
}

function makePdf_(folder, r, v, today, prefix) {
  const name = prefix + 'Volunteer hours - ' + r.name.replace(/[\\\/:*?"<>|]/g, '-') + ' - ' +
    iso_(r.from === null ? v.first : r.from) + ' to ' + iso_(r.until === null ? today : r.until);
  const old = folder.getFilesByName(name + '.pdf');
  while (old.hasNext()) old.next().setTrashed(true);   // a re-made letter replaces the old PDF
  const doc = DocumentApp.create(name);
  const file = DriveApp.getFileById(doc.getId());
  file.moveTo(folder);
  render_(doc.getBody(), r, v, today);
  doc.saveAndClose();
  const blob = file.getAs('application/pdf').setName(name + '.pdf');
  const pdf = folder.createFile(blob);
  if (!KEEP_DOCS) file.setTrashed(true);
  return { name: name, blob: blob, url: pdf.getUrl() };
}

function render_(body, r, v, today) {
  const H = DocumentApp.ParagraphHeading;
  body.setMarginTop(54).setMarginBottom(54).setMarginLeft(54).setMarginRight(54);
  const first = body.getParagraphs()[0];
  first.setText(ORG_NAME);
  first.setHeading(H.HEADING1);
  ORG_LINES.concat(ORG_EIN ? ['EIN ' + ORG_EIN] : []).forEach(function (line) { body.appendParagraph(line).setHeading(H.NORMAL); });
  body.appendParagraph(show_(today)).setHeading(H.NORMAL);
  body.appendParagraph(r.addressedTo || 'To whom it may concern').setHeading(H.NORMAL);
  body.appendParagraph('Verification of volunteer hours: ' + r.name).setHeading(H.HEADING2);
  const span = v.first === v.last ? 'on ' + show_(v.first) : 'between ' + show_(v.first) + ' and ' + show_(v.last);
  body.appendParagraph('This letter confirms that ' + r.name + ' completed ' + hrs_(v.total) + ' hours of volunteer service with ' +
    ORG_NAME + ' ' + span + ', on ' + v.dayCount + (v.dayCount === 1 ? ' day' : ' separate days') +
    (r.purpose ? ', for ' + r.purpose : '') + '. The hours are taken from our volunteer attendance records' +
    (r.from !== null || r.until !== null ? ' for ' + period_(r, today) : '') + '.').setHeading(H.NORMAL);
  if (r.required) {
    body.appendParagraph(v.total >= r.required * 100
      ? 'This meets the ' + hrs_(r.required * 100) + ' hours required.'
      : 'This is ' + hrs_(v.total) + ' of the ' + hrs_(r.required * 100) + ' hours required; ' +
        hrs_(r.required * 100 - v.total) + ' hours remain.').setHeading(H.NORMAL);
  }
  body.appendParagraph('Service performed').setHeading(H.HEADING3);
  const acts = [['Activity', 'Hours']];
  v.activities.forEach(function (a) { acts.push([a.name, hrs_(a.cents)]); });
  table_(body, acts, [1]);
  if (LIST_EACH_DAY) {
    body.appendParagraph('Dates of service').setHeading(H.HEADING3);
    const showSup = v.days.some(function (x) { return x.sup; });
    const rows = [showSup ? ['Date', 'Activity', 'Supervisor', 'Hours'] : ['Date', 'Activity', 'Hours']];
    v.days.forEach(function (x) {
      const a = x.activity || 'Volunteer service';
      rows.push(showSup ? [show_(x.day), a, x.sup, hrs_(x.cents)] : [show_(x.day), a, hrs_(x.cents)]);
    });
    rows.push(showSup ? ['Total', '', '', hrs_(v.total)] : ['Total', '', hrs_(v.total)]);
    table_(body, rows, [rows[0].length - 1]).getRow(rows.length - 1).editAsText().setBold(true);
  }
  body.appendParagraph('To confirm these hours, contact ' + SIGNER_NAME + ', ' +
    SIGNER_TITLE + ', at ' + SIGNER_CONTACT + '.').setHeading(H.NORMAL);
  body.appendParagraph('Sincerely,').setHeading(H.NORMAL);
  body.appendParagraph('').setHeading(H.NORMAL);
  body.appendParagraph('______________________________').setHeading(H.NORMAL);
  body.appendParagraph(SIGNER_NAME + ', ' + SIGNER_TITLE).setHeading(H.NORMAL);
  body.appendParagraph(ORG_NAME).setHeading(H.NORMAL);
}

function period_(r, today) {
  if (r.from !== null && r.until !== null) return show_(r.from) + ' to ' + show_(r.until);
  if (r.from !== null) return show_(r.from) + ' to ' + show_(today);
  return 'the period up to ' + show_(r.until);
}

function table_(body, cells, rightCols) {
  const t = body.appendTable(cells);
  t.getRow(0).editAsText().setBold(true);
  for (let r = 0; r < cells.length; r++) {
    rightCols.forEach(function (c) {
      t.getCell(r, c).getChild(0).asParagraph().setAlignment(DocumentApp.HorizontalAlignment.RIGHT);
    });
  }
  return t;
}

function mail_(r, v, blob, to, emails) {
  const m = {
    to: to.join(','),
    subject: (PREVIEW ? '[PREVIEW to ' + emails.join(', ') + '] ' : '') + 'Your volunteer hours letter from ' + ORG_NAME,
    body: 'Hello ' + r.name + ',\n\nAttached is the letter confirming your ' + hrs_(v.total) + ' volunteer hours with ' + ORG_NAME +
      '. If the place you are sending it to needs a signed paper copy or its own form, just reply and we will sign it.\n\n' +
      'Thank you for your time.\n\n' + SIGNER_NAME + '\n' + SIGNER_TITLE + ', ' + ORG_NAME,
    name: ORG_NAME,
    attachments: [blob]
  };
  if (REPLY_TO) m.replyTo = REPLY_TO;
  return m;
}

function summary_(r) {
  const out = [(r.preview ? 'PREVIEW: ' : '') + r.made + ' verification letter PDF(s) made.' +
    (r.emailed ? ' Emailed ' + r.emailed + (r.preview ? ' (to you only).' : '.') : '')];
  if (r.alreadyDone) out.push(r.alreadyDone + ' request(s) already have a letter (clear the Letter cell to make it again).');
  if (r.left) out.push(r.left + ' request(s) left' + (r.quota ? ' (daily email quota reached)' : r.timeUp ? ' (time limit)' : '') + '. Run it again to continue.');
  if (r.short.length) out.push('Below the required hours (the letter says how many remain):\n' + r.short.join('\n'));
  if (r.notCounted.length) out.push('Hours in the log that are not verified yet:\n' + r.notCounted.join('\n'));
  if (r.noHours.length) out.push('No verified hours found, no letter made: ' + r.noHours.join(', '));
  if (r.noEmail.length) out.push('No valid Email, PDF made but not sent: ' + r.noEmail.join(', '));
  if (r.duplicates.length) out.push('Possible double entries, check them:\n' + r.duplicates.slice(0, 10).join('\n'));
  const bad = r.badRequests.concat(r.skippedRows);
  if (bad.length) out.push('Rows skipped:\n' + bad.slice(0, 15).join('\n') + (bad.length > 15 ? '\n...and ' + (bad.length - 15) + ' more' : ''));
  return out.join('\n\n');
}

// ---- small helpers ----
function finder_(header) {
  const h = (header || []).map(function (x) { return String(x).trim().toLowerCase(); });
  return function (name) { return h.indexOf(name.toLowerCase()); };
}

function either_(col, a, b) {
  return col(a) >= 0 ? col(a) : col(b);
}

function norm_(s) {
  return String(s || '').trim().replace(/\s+/g, ' ').toLowerCase();
}

function emails_(s) {
  const list = String(s || '').split(/[,;]/).map(function (x) { return x.trim(); }).filter(String);
  const ok = list.length > 0 && list.every(function (x) { return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(x); });
  return ok ? list : null;
}

function number_(s) {
  if (typeof s === 'number') return s;
  const t = String(s).replace(/\s/g, '').replace(/,/g, '.');
  return /^\d+(\.\d+)?$/.test(t) ? Number(t) : NaN;
}

function toDay_(v, tz) {
  if (v instanceof Date) return isNaN(v.getTime()) ? null : dayNum_(Utilities.formatDate(v, tz, 'yyyy-MM-dd'));
  return typeof v === 'string' ? dayNum_(v.trim()) : null;
}

// Dates are whole days counted from 1970-01-01, so time zones and daylight saving can't shift them.
function dayNum_(s) {
  const m = /^(\d{4})-(\d{1,2})-(\d{1,2})$/.exec(String(s));
  if (!m) return null;
  const n = Date.UTC(+m[1], +m[2] - 1, +m[3]) / DAY;
  const back = ymd_(n);
  return back.y === +m[1] && back.m === +m[2] && back.d === +m[3] ? n : null;
}

function ymd_(n) {
  const d = new Date(n * DAY);
  return { y: d.getUTCFullYear(), m: d.getUTCMonth() + 1, d: d.getUTCDate() };
}

function show_(n) {
  const t = ymd_(n);
  return MONTHS[t.m - 1] + ' ' + t.d + ', ' + t.y;
}

function iso_(n) {
  const t = ymd_(n);
  return t.y + '-' + String(t.m).padStart(2, '0') + '-' + String(t.d).padStart(2, '0');
}

// Hours are kept in hundredths so 2.25 + 1.5 adds up exactly; shown without trailing zeros.
function hrs_(cents) {
  return String(Math.round(cents) / 100);
}

What the script does

Step 5: using the volunteer shift guide's Signups tab

If you schedule with the volunteer shift guide, you already have the hours: its Signups tab has Name, Email, Status and the Date, Role and Hours helper columns. Set HOURS_SHEET = 'Signups'. The script reads Name as the volunteer and Role as the activity, and when a Status column is present it counts only rows marked Attended (or Completed, Verified, Approved, Done), so No-show, Cancelled, Waitlist and shifts not yet marked are left out. Marking Attended after each shift is then your verification step.

Step 6: signing and sending

A letter is only as good as its signature. The simplest routine: print the PDF, have the signer sign it in ink, and scan it or hand it over. If your organization signs PDFs electronically, that works too, as long as the school or court accepts it; ask them. Many places will contact the signer to confirm, so SIGNER_CONTACT should be a phone number or address someone actually answers.

To email the unsigned PDF to the volunteer instead (useful when the receiving office only needs the record, or for the volunteer's own files), set EMAIL_LETTERS = true. Each PDF goes to the request's Email from your account with ORG_NAME as the sender name, and the message offers a signed copy on request; replies go to REPLY_TO if set. Try it with PREVIEW = true first: preview emails come only to you, with the real recipient in the subject. The script checks your remaining daily Apps Script email quota before each email (100 recipients a day on a consumer Gmail account, 1,500 on Google Workspace) and stops when it would run out; the next run carries on.

Tips

Want letters on your own letterhead template? SheetWeave (disclosure: we make it) is a Google Sheets add-on that fills a Google Docs template with each row's column values and saves a Doc, a PDF, or both in a Drive folder you choose, writing the links back to the row. Point it at the Requests tab and it makes one letter per request from your own designed template, with your logo and wording: {{Volunteer}}, {{Verified hours so far}}, {{From}}, {{To}}, {{Purpose}} and any other column. For the day-by-day table, use the script above. 14-day free trial, no credit card to start. SheetWeave is on the Google Workspace Marketplace.
See SheetWeave

Related Google Sheets guides

Instructions refer to Google Sheets, Google Docs, Google Drive and Apps Script as they worked on November 16, 2026, and to the US Courts and Google pages cited as they stood that day. Not legal advice, and not affiliated with Google, any court or any school. Google Sheets, Google Docs and Google Drive are trademarks of Google LLC. Check each letter against your own records before anyone signs it. Questions or corrections: hello@loomwise.app.