Hi, you created the following code for me which work great.  I want to iterate on this version.  In the Transactions Worksheet once a transaction has been categorized, you create a new Column called Processed.  I like this, rather than put Yes, could you enter the Category name in the appropriate field.  i.e.  Use one of the following: Revenue	Donations	House	Food	Auto	Debts	E&R	Clothes	Investments	Health care	Life & disability Insurance	Misc.  Here is the code: /**
 * Main function to import and categorize transactions.
 */
function importAndCategorizeTransactions() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var transactionsSheet = ss.getSheetByName("Transactions");
  var expensesSheet = ss.getSheetByName("Expenses");
  
  // Validate Sheet Existence
  if (!transactionsSheet) {
    SpreadsheetApp.getUi().alert("The 'Transactions' sheet does not exist.");
    return;
  }
  
  if (!expensesSheet) {
    SpreadsheetApp.getUi().alert("The 'Expenses' sheet does not exist.");
    return;
  }

  // Define Constants
  var TRANSACTION_START_ROW = 2; // Transactions start at Row 2
  var EXPENSES_START_ROW = 6;    // Expenses data starts at Row 6
  var PROCESSED_COLUMN = 4;      // Column D (1-based index)

  // Check if 'Processed' header exists; if not, add it
  var processedHeader = transactionsSheet.getRange(1, PROCESSED_COLUMN).getValue(); // Row 1, Column D
  if (processedHeader.toString().trim().toUpperCase() !== "PROCESSED") {
    transactionsSheet.getRange(1, PROCESSED_COLUMN).setValue("Processed");
  }

  // Fetch Transactions Data (Columns A-C and D)
  var lastTransactionRow = transactionsSheet.getLastRow();
  if (lastTransactionRow < TRANSACTION_START_ROW) {
    SpreadsheetApp.getUi().alert("No transactions found to process.");
    return;
  }
  
  // Fetch data from Columns A-C and D (Processed)
  var transactionDataRange = transactionsSheet.getRange(TRANSACTION_START_ROW, 1, lastTransactionRow - TRANSACTION_START_ROW + 1, PROCESSED_COLUMN);
  var transactionsData = transactionDataRange.getValues();
  
  // Fetch Expenses Category Headers (Row 4, Columns E onwards)
  var expensesHeaderRange = expensesSheet.getRange(4, 5, 1, expensesSheet.getLastColumn() - 4); // Row 4, Columns E onwards
  var expensesHeaders = expensesHeaderRange.getValues()[0]; // First (and only) row
  
  // Create Category to Column Mapping
  var categoryMap = {};
  for (var c = 0; c < expensesHeaders.length; c++) {
    var category = expensesHeaders[c].toString().trim().toUpperCase();
    if (category !== "") {
      categoryMap[category] = c + 5; // Column E is 5
    }
  }
  
  // Iterate Through Each Transaction
  for (var i = 0; i < transactionsData.length; i++) {
    var row = transactionsData[i];
    var processed = row[PROCESSED_COLUMN - 1]; // Column D is index 3 (0-based indexing)
    
    // Skip if already processed
    if (processed && processed.toString().toLowerCase() === "yes") {
      continue;
    }
    
    // Extract Transaction Details
    var transactionDateRaw = row[0]; // Column A
    var transactionDesc = row[1];     // Column B
    var transactionAmount = row[2];   // Column C
    
    // Parse Date to Extract Day
    var transactionDay = extractDay(transactionDateRaw);
    
    if (transactionDay === null) {
      SpreadsheetApp.getUi().alert("Unable to parse date in 'Transactions' sheet at row " + (TRANSACTION_START_ROW + i) + ". Skipping this transaction.");
      // Mark as processed to avoid repeated alerts
      transactionsSheet.getRange(TRANSACTION_START_ROW + i, PROCESSED_COLUMN).setValue("Yes");
      continue;
    }
    
    // Validate Day
    if (transactionDay < 1 || transactionDay > 31) {
      SpreadsheetApp.getUi().alert("Invalid day (" + transactionDay + ") extracted from date in 'Transactions' sheet at row " + (TRANSACTION_START_ROW + i) + ". Skipping this transaction.");
      // Mark as processed to avoid repeated alerts
      transactionsSheet.getRange(TRANSACTION_START_ROW + i, PROCESSED_COLUMN).setValue("Yes");
      continue;
    }
    
    // Prompt User for Category
    var ui = SpreadsheetApp.getUi();
    var availableCategories = Object.keys(categoryMap).join(", ");
    var promptMsg = "Transaction Details:\n\n" +
                    "Date: " + formatDate(transactionDateRaw) + "\n" +
                    "Description: " + transactionDesc + "\n" +
                    "Amount: $" + parseFloat(transactionAmount).toFixed(2) + "\n\n" +
                    "Enter category for this transaction (e.g., " + availableCategories + "):";
    var response = ui.prompt("Categorize Transaction", promptMsg, ui.ButtonSet.OK_CANCEL);
    
    // Handle User Response
    if (response.getSelectedButton() == ui.Button.CANCEL) {
      SpreadsheetApp.getUi().alert("Transaction categorization canceled. Remaining transactions will not be processed.");
      return;
    }
    
    var categoryInput = response.getResponseText().trim().toUpperCase();
    
    if (categoryInput === "") {
      categoryInput = "MISC"; // Default to 'Misc' if no input
    }
    
    // Validate Category
    if (!categoryMap.hasOwnProperty(categoryInput)) {
      var availableCategoriesList = Object.keys(categoryMap).join(", ");
      SpreadsheetApp.getUi().alert("Category '" + categoryInput + "' not found in 'Expenses' sheet.\n\nAvailable categories: " + availableCategoriesList + "\n\nPlease ensure you enter a valid category. This transaction will be skipped.");
      // Mark as processed to skip this transaction
      transactionsSheet.getRange(TRANSACTION_START_ROW + i, PROCESSED_COLUMN).setValue("Yes");
      continue;
    }
    
    var categoryColumn = categoryMap[categoryInput];
    
    // Locate Row in Expenses Sheet Based on Day
    var expensesLastRow = expensesSheet.getLastRow();
    var dayRow = -1;
    
    // Assuming Dates (1-31) are in Column A starting from Row 6
    var dateColumnRange = expensesSheet.getRange(EXPENSES_START_ROW, 1, expensesLastRow - EXPENSES_START_ROW + 1, 1);
    var dateValues = dateColumnRange.getValues();
    
    for (var r = 0; r < dateValues.length; r++) {
      var cellDay = dateValues[r][0];
      if (cellDay === transactionDay) {
        dayRow = EXPENSES_START_ROW + r;
        break;
      }
    }
    
    if (dayRow === -1) {
      SpreadsheetApp.getUi().alert("No matching day (" + transactionDay + ") found in 'Expenses' sheet for transaction at row " + (TRANSACTION_START_ROW + i) + ". Skipping this transaction.");
      // Mark as processed to skip this transaction
      transactionsSheet.getRange(TRANSACTION_START_ROW + i, PROCESSED_COLUMN).setValue("Yes");
      continue;
    }
    
    // Prepare Transaction Entry (Only Amount)
    var transactionAmountValue = parseFloat(transactionAmount).toFixed(2); // e.g., "150.00" or "-75.50"
    var numericAmount = parseFloat(transactionAmountValue); // Convert to number: 150.00 or -75.50
    
    // Fetch Existing Cell Value in Expenses Sheet
    var targetCell = expensesSheet.getRange(dayRow, categoryColumn);
    var existingValue = targetCell.getValue();
    
    var newTotal = numericAmount;
    
    if (typeof existingValue === 'number') {
      newTotal = existingValue + numericAmount;
    } else if (typeof existingValue === 'string') {
      // Attempt to parse all amounts if stored as text entries
      // Example: "$50.00\n$25.00"
      var amountLines = existingValue.split('\n');
      var sumExisting = 0;
      for (var j = 0; j < amountLines.length; j++) {
        // Extract numerical value from each line
        var amt = parseFloat(amountLines[j].replace(/[^-\d\.]/g, ''));
        if (!isNaN(amt)) {
          sumExisting += amt;
        }
      }
      newTotal = sumExisting + numericAmount;
    }
    // Else (empty or other types), newTotal remains as numericAmount
    
    // Round to two decimal places to avoid floating point issues
    newTotal = Math.round((newTotal + Number.EPSILON) * 100) / 100;
    
    // Set the new total back to the Expenses sheet
    // Assumes the cell is formatted as Currency or Number
    targetCell.setValue(newTotal);
    targetCell.setNumberFormat("$#,##0.00"); // Optional: Ensures currency format
    
    // Mark Transaction as Processed
    transactionsSheet.getRange(TRANSACTION_START_ROW + i, PROCESSED_COLUMN).setValue("Yes");
  }
  
  SpreadsheetApp.getUi().alert("All transactions have been processed and categorized successfully.");
}

/**
 * Extracts the day from a date input, ignoring the month.
 * @param {string|Date} dateInput - The date input which can be a Date object or a string.
 * @return {number|null} - Returns the day as a number (1-31) or null if parsing fails.
 */
function extractDay(dateInput) {
  if (dateInput instanceof Date) {
    return dateInput.getDate();
  } else if (typeof dateInput === 'string') {
    // Attempt to parse the day from the string
    // Assuming formats like "Dec-01", "2023-12-01", "12/01/2023", etc.
    var parsedDate = new Date(dateInput);
    if (!isNaN(parsedDate)) {
      return parsedDate.getDate();
    } else {
      // If parsing fails, attempt to extract the day manually
      var dayMatch = dateInput.match(/(\d{1,2})$/);
      if (dayMatch && dayMatch[1]) {
        var day = parseInt(dayMatch[1], 10);
        if (!isNaN(day) && day >= 1 && day <= 31) {
          return day;
        }
      }
    }
  }
  return null; // Failed to parse day
}

/**
 * Formats the date input into a readable string.
 * @param {string|Date} dateInput - The date input which can be a Date object or a string.
 * @return {string} - Returns the formatted date string.
 */
function formatDate(dateInput) {
  if (dateInput instanceof Date) {
    return Utilities.formatDate(dateInput, Session.getScriptTimeZone(), "EEE MMM dd yyyy");
  } else if (typeof dateInput === 'string') {
    var parsedDate = new Date(dateInput);
    if (!isNaN(parsedDate)) {
      return Utilities.formatDate(parsedDate, Session.getScriptTimeZone(), "EEE MMM dd yyyy");
    } else {
      return dateInput; // Return as-is if unable to parse
    }
  }
  return "";
}

/**
 * Adds a custom menu to the Google Sheets UI upon opening the spreadsheet.
 */
function onOpen() {
  var ui = SpreadsheetApp.getUi();
  ui.createMenu('Transaction Tools')
    .addItem('Import & Categorize Transactions', 'importAndCategorizeTransactions')
    .addToUi();
}