Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
Power Lifting Lever Belt
SkullVamp
Updated:
Saturday at 10:32 PM
Ad icon
port.lk Domain for sale
Lankan-Tech
Updated:
Saturday at 3:55 PM
Colombo
Kaduwela - Two Storey House for Sale
dilrasan
Updated:
Thursday at 2:23 PM
Ad icon
Wechat qr verification
Pawan2005
Updated:
Thursday at 1:28 AM
🚀 GOOGLE AI PRO 18 MONTHS ACTIVATION 🚀
sayuru bandara
Updated:
Wednesday at 5:34 PM
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
ElaKiri Help
excel or google sheet marco help
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="NEMISIS" data-source="post: 30572452" data-attributes="member: 494668"><p>Create a google sheet with your data.</p><p>Open the sheet</p><p>then go to Extensions > Apps Script</p><p>This will open your app script project, give it a name, and you need to edit the script, as per your logic</p><p></p><p>Here is my sample sheet structure</p><p></p><p></p><p>[ATTACH=full]247419[/ATTACH]</p><p></p><p>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.</p><p></p><p>[CODE]</p><p>function checkExpiringDates() {</p><p> const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet1"); // Change to your sheet name</p><p> const LAST_ROW = sheet.getLastRow();</p><p> const EXPIRATION_COLUMN = 3; // Column C (Expiration Date)</p><p> const NAME_COLUMN = 1; // Column A (Name)</p><p> const DAYS_BEFORE_EXPIRATION = 90; // 3 months = 90 days</p><p> const RECIPIENTS = "recipient1@example.com, recipient2@example.com"; // Main recipients (separated by commas)</p><p> const CC_RECIPIENTS = "cc1@example.com, cc2@example.com"; // CC recipients (optional)</p><p> </p><p> const data = sheet.getRange(2, 1, LAST_ROW - 1, 3).getValues(); // Get all rows except headers</p><p> const today = new Date();</p><p> const futureDate = new Date();</p><p> futureDate.setDate(today.getDate() + DAYS_BEFORE_EXPIRATION);</p><p></p><p> let expiringItems = [];</p><p></p><p> for (let i = 0; i < data.length; i++) {</p><p> let name = data[i][NAME_COLUMN - 1]; // Name from Column A</p><p> let expDate = data[i][EXPIRATION_COLUMN - 1]; // Expiration date from Column C</p><p></p><p> if (expDate instanceof Date) { // Ensure it's a valid date</p><p> if (expDate >= today && expDate <= futureDate) {</p><p> expiringItems.push(`- ${name} (Expiring on: ${expDate.toDateString()})`);</p><p> }</p><p> }</p><p> }</p><p></p><p> if (expiringItems.length > 0) {</p><p> let subject = "Expiration Alert - Google Sheets";</p><p> let body = `The following items are expiring within the next 3 months:\n\n${expiringItems.join("\n")}`;</p><p></p><p> // Send email with multiple recipients and CC</p><p> MailApp.sendEmail({</p><p> to: RECIPIENTS,</p><p> cc: CC_RECIPIENTS,</p><p> subject: subject,</p><p> body: body</p><p> });</p><p> }</p><p>}</p><p></p><p>[/CODE]</p><p></p><p>Then you can simply save and run the script to test.</p><p></p><p>Next step is to setup the time trigger, to do that</p><p>Click the clock icon in the left pane, in your script project,</p><p>Then click triggers, add trigger (Bottom right corner button)</p><p></p><p>[ATTACH=full]247420[/ATTACH]</p><p></p><p>You have to update the script to add your emails, You can also pick email from a column too.</p><p></p><p>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.</p><p>Also the email sender would be the one who owns the google sheet, You may create a new google account for this automation.</p><p></p><p>Keep in mind, there are some limitations,</p><p></p><p>[ATTACH=full]247421[/ATTACH]</p><p></p><p></p><p>Script is configurable, you can simply configure the column which has your expiration date.</p></blockquote><p></p>
[QUOTE="NEMISIS, post: 30572452, member: 494668"] 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 [ATTACH type="full" width="389px" alt="Screenshot 2025-02-28 at 9.15.01 AM.png"]247419[/ATTACH] 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 = "recipient1@example.com, recipient2@example.com"; // Main recipients (separated by commas) const CC_RECIPIENTS = "cc1@example.com, cc2@example.com"; // 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 }); } } [/CODE] 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) [ATTACH type="full" width="253px" alt="Screenshot 2025-02-28 at 9.18.09 AM.png"]247420[/ATTACH] 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, [ATTACH type="full" width="391px" alt="Screenshot 2025-02-28 at 9.27.56 AM.png"]247421[/ATTACH] Script is configurable, you can simply configure the column which has your expiration date. [/QUOTE]
Insert quotes…
Verification
Dawasata paya keeyak thibeda?
Post reply
Top
Bottom