excel or google sheet marco help

Duckduck

Well-known member
  • Mar 4, 2023
    1,691
    927
    113
    me pahala thiyena chart eke thiyena details expired wena dawasata masa 3kata kalin supplierta expire date remind karala automatic mail ekak yana widihata set karanne kohomada. thawa keepa denek cc wennath ona. mata excel gana knowlegede eka godak adui. mata support ekak deepan. office eke wadak.

    Hanger Ref. NumberFabric Techsubmit DateItem numberDeptEmail subjectMill nameMill statusmill onboarding statusFabric Quality Ref NumberCompositionConstructionGSMFabric Spec statusLK NumberTarget base approval datebase approval date1st Submission date1st submission status2nd Submission date2nd submission status3rd Submission date3rd submission statusFabric PP meeting requiredFabric PP completed dateDate to start work on base renewal (base approved date+ 300 days)
    1Thanuja11/20/2023BGJOCEAN LANKAExistingYesLYSJ018414/FS100% Cottonsingle Jersey185gsmYes11/22/20239/17/2024

    bump
    ------ Post added on Feb 27, 2025 at 10:47 AM
     

    racool

    Well-known member
  • Sep 18, 2006
    1,682
    83
    48
    This might be Hell
    Merchandiser kenek wage.. Oya wade karanna macro ekakin witharakma bari wei. Email integration eka karannath one nisa. anika email eka yanna one address ekata 2FA ehema daalanam tikak naduwak.
    Google sheet ekaka appscript ekakin wade lesiyen karanna puluwan wei gmail ekemna mail ekak yanna.
     
    Last edited:

    NEMISIS

    Well-known member
  • Nov 13, 2013
    11,348
    19,442
    113
    Colombo
    Macro ගැන නං දන්නෑ
    ඒත් google sheet එකක් නං තියෙන්නෙ, AppScript එකක් ලියලා ඒක හැමදාම රන් වෙන්න හදන්න පුලුවන්, එතකොට ඩේට් එක චෙක් කරලා email එක යවන්න හදාගන්න පුලුවන්
    පොඩි අවුලකට තියෙන්නෙ Appscript එක 12ට රන්න වෙන්න කියලා දැම්මම පොඩි ඩිලේ එකක් සෙට් වෙන්න පුලුවන් 12.01, 12.02 වෙන්න පුලුවන්. ඒක නිසා රිමයින්ඩර් එක යැවුවද නැද්ද කියන එක වෙනම කොලම් එකක ෆිල් වෙන්න වගේ හදාගන්න වෙයි.
    විනාඩි 5ක වැඩක් තියෙන්නෙ.
     

    Duckduck

    Well-known member
  • Mar 4, 2023
    1,691
    927
    113
    Macro ගැන නං දන්නෑ
    ඒත් google sheet එකක් නං තියෙන්නෙ, AppScript එකක් ලියලා ඒක හැමදාම රන් වෙන්න හදන්න පුලුවන්, එතකොට ඩේට් එක චෙක් කරලා email එක යවන්න හදාගන්න පුලුවන්
    පොඩි අවුලකට තියෙන්නෙ Appscript එක 12ට රන්න වෙන්න කියලා දැම්මම පොඩි ඩිලේ එකක් සෙට් වෙන්න පුලුවන් 12.01, 12.02 වෙන්න පුලුවන්. ඒක නිසා රිමයින්ඩර් එක යැවුවද නැද්ද කියන එක වෙනම කොලම් එකක ෆිල් වෙන්න වගේ හදාගන්න වෙයි.
    විනාඩි 5ක වැඩක් තියෙන්නෙ.
    Ane mata therenna bn, ape it eke huththa danneth na. Puluwannam nam mata example ekak karala deepan. Time eke prashnayak dawasak dekak delay wennathuwa mail eka yanawanam athi bn

    Bump
    ------ Post added on Feb 27, 2025 at 1:26 PM
     

    NEMISIS

    Well-known member
  • Nov 13, 2013
    11,348
    19,442
    113
    Colombo
    Ane mata therenna bn, ape it eke huththa danneth na. Puluwannam nam mata example ekak karala deepan. Time eke prashnayak dawasak dekak delay wennathuwa mail eka yanawanam athi bn

    Bump
    ------ Post added on Feb 27, 2025 at 1:26 PM
    pm ekak dala thiyanna
    man reta reply ekak dannam. nat nam amathaka wei
     
    • Like
    Reactions: Duckduck and wqe123

    NEMISIS

    Well-known member
  • Nov 13, 2013
    11,348
    19,442
    113
    Colombo
    Create a google sheet with your data.
    Open the sheet
    then go to Extensions > Apps Script
    This will open your app script project, give it a name, and you need to edit the script, as per your logic

    Here is my sample sheet structure


    Screenshot 2025-02-28 at 9.15.01 AM.png


    This is the script (Generated via ChatGPT, didn't test the script in detail), you have to update the script based on your need. If you need some help with the script, you can ask, me or someone else can help.

    Code:
    function checkExpiringDates() {
      const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet1"); // Change to your sheet name
      const LAST_ROW = sheet.getLastRow();
      const EXPIRATION_COLUMN = 3; // Column C (Expiration Date)
      const NAME_COLUMN = 1; // Column A (Name)
      const DAYS_BEFORE_EXPIRATION = 90; // 3 months = 90 days
      const RECIPIENTS = "[email protected], [email protected]"; // Main recipients (separated by commas)
      const CC_RECIPIENTS = "[email protected], [email protected]"; // CC recipients (optional)
     
      const data = sheet.getRange(2, 1, LAST_ROW - 1, 3).getValues(); // Get all rows except headers
      const today = new Date();
      const futureDate = new Date();
      futureDate.setDate(today.getDate() + DAYS_BEFORE_EXPIRATION);
    
      let expiringItems = [];
    
      for (let i = 0; i < data.length; i++) {
        let name = data[i][NAME_COLUMN - 1]; // Name from Column A
        let expDate = data[i][EXPIRATION_COLUMN - 1]; // Expiration date from Column C
    
        if (expDate instanceof Date) { // Ensure it's a valid date
          if (expDate >= today && expDate <= futureDate) {
            expiringItems.push(`- ${name} (Expiring on: ${expDate.toDateString()})`);
          }
        }
      }
    
      if (expiringItems.length > 0) {
        let subject = "Expiration Alert - Google Sheets";
        let body = `The following items are expiring within the next 3 months:\n\n${expiringItems.join("\n")}`;
    
        // Send email with multiple recipients and CC
        MailApp.sendEmail({
          to: RECIPIENTS,
          cc: CC_RECIPIENTS,
          subject: subject,
          body: body
        });
      }
    }

    Then you can simply save and run the script to test.

    Next step is to setup the time trigger, to do that
    Click the clock icon in the left pane, in your script project,
    Then click triggers, add trigger (Bottom right corner button)

    Screenshot 2025-02-28 at 9.18.09 AM.png


    You have to update the script to add your emails, You can also pick email from a column too.

    When you are running this for the first time, it will warn you saying this is not approved app etc, you will have to trust the project and go ahed.
    Also the email sender would be the one who owns the google sheet, You may create a new google account for this automation.

    Keep in mind, there are some limitations,

    Screenshot 2025-02-28 at 9.27.56 AM.png



    Script is configurable, you can simply configure the column which has your expiration date.
     
    Last edited: