Automatically increase the dates in two cells once they have passed

Summary:

Although I'm not a programmer, I've managed to incorporate some complex coding into a Google Sheets document for tracking my team's projects. This includes multiple-variable dropdown menus and integration with Google Calendar to monitor project development.

Why I'm Seeking Help:

While I usually piece together code fragments from internet forums successfully, this time I'm struggling to find the information I need to proceed.

What I am Looking For:

I have 5 cells that are structured as follows:

Date start - Date end - date code* - number** - Priority***

*I need a script to add the date range to Google Calendar.

** & *** The "number" cell should display values based on the value in the "Priority" cell. For example, if "Weekly" is selected as the priority, the "number" column will show "7" in the corresponding cell (monthly = 30, etc.).


I'm looking for assistance in creating a script that functions as follows:

If I set the priority to weekly, it will display "7" in the "number" column. Then, every time the "Date end" has passed, it will automatically add 7 days to both the "Date start" and "Date end."

This setup will allow me to continuously track our projects effectively.

Thank you in advance for any guidance provided.


PS: While I've come across similar discussions involving SQL, I lack the expertise to implement the suggested solutions.

Edit: View Spreadsheet Image eDIT2: Spreadsheet with an increment column

Answer №1

Regarding the data set and description, VBA may not be necessary for achieving increment by adding +1 to the reference pointing to the previous cell. For instance, if cell A1 is formatted as a Date, you can input in cell B1: =A1+1, then in cell C1: =B1+1, and so forth. The outcome should display as follows:

A           B           C      
9/1/2017    9/2/2017    9/3/2017

This process could be enhanced with a simple condition to only show the incremented value if the preceding cell is not empty, such as: =IF(A1,A1+1,"")

In your scenario, it might involve cell F1 containing =IF(E1,E1+1,"").

It's worth noting that the underlying value of Date is essentially an Integer value (with Time represented as the decimal part), allowing arithmetic operations to be performed.

A more versatile solution could utilize the Excel DATE() Worksheet formula, like demonstrated in this example (adding 1 month to the date entered in cell A1):

=DATE(YEAR(A1), MONTH(A1)+1, DAY(A1))

To incorporate additional logic, consider utilizing the Excel Worksheet IF() statement, as shown in this sample scenario where cell B1 contains:

=A1+IF(C1="week",7,1)

A           B           C
9/1/2017    9/8/2017    week

Based on the IF() condition, it will add either 7 days if C1 contains the word "week," or 1 day otherwise. Further complexity can be achieved with nested IF() statements.

I trust this information proves helpful.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

jQuery element with listener not triggering as expected

I'm facing some confusion while working on this issue. I am attempting to create a dynamic form where users can add descriptions, checkboxes, and number inputs as they please. Currently, I have developed a simple dynamic form using jQuery, which allow ...

Manipulating datetime format within an input element of type date using Angular's ngModel

I have a date input in my form that is populated from the controller with a string value for 'dateOfDiagnosis'. The format of this string includes the time as well, like this: "2010-09-08T00:00:00" To bind this value to an input field in Angu ...

Is JavaScript Promise Chaining Allowed?

I have a question regarding my code, despite it currently functioning correctly. Specifically, I'm wondering if the sequence of promises in my database is valid. Promise 1 must be fulfilled before moving on to Promise 2 because I rely on the data and ...

Angular is throwing a RangeError due to exceeding the maximum call stack size

Encountering a stackOverflow error in my Angular app. (see updates at the end) The main issue lies within my component structure, which consists of two components: the equipment component with equipment information and the socket component displaying conn ...

Combining arrays in Javascript that share the same key by utilizing a loop

Can you advise on the most effective method to restructure an array for desired output? My goal is to combine all key values, whether in arrays or not, into objects with the same name key. Here is my current array: brands: [ 0:ZARA: {product: "ZARA Blac ...

What is the functionality of the toArray method?

var retrieveDocs = function (db, callback) { var collection = db.collection('tours'); collection.find({ "tourPackage": "Snowboard Cali" }).toArray(function (err, data) { console.log(data); callback; }) } Is there a p ...

Error encountered in Node/Express application: EJS partials used with Angular, causing Uncaught ReferenceError: angular is not defined

I seem to be missing something important here as I attempt to incorporate ejs partials into a single-page Angular app. Every time I try, I encounter an Uncaught ReferenceError: angular is not defined in my partial. It seems like using ejs partials instead ...

Choosing a particular 2D array based on another variable in jQuery and JavaScript

Within my project, I am utilizing 2D arrays to append specific divs under particular circumstances. In an effort to streamline and enhance the code, I attempted to create a variable that would determine which array to utilize based on the id of an HTML < ...

How can I enhance data from an AJAX callback in Mapbox with an additional layer?

With the code snippet below, I am aiming to utilize event data from an API to create a mapbox layer. This layer will be used to place markers and symbols on the map. However, I prefer not to use Mapbox markers as they cause issues with my code. I have suc ...

Guide on darkening the surrounding div of an alert to give it a modal-like effect

I want to display an alert to the user in a visually appealing way. To achieve this, I am utilizing Bootstrap's alert class. Here is how I am showing the user a div: <div class="alert alert-warning alert-dismissible" role="alert"> Some text ...

adjust time in jQuery AJAX request when a button is clicked

I have the following code snippet that triggers when a button is clicked. When a user clicks on a button, I want to show a progress bar or waiting image in the browser for 5 seconds. How can I set a timeout and display the progress bar or waiting image wh ...

Having trouble with validation messages not displaying correctly in Angular after removing a value. What is the correct approach to fix this issue

I've encountered an issue with Angular validation where it's triggering validation on page load, which is not desired. Additionally, when I enter a value, the validation message disappears, but if I return to the textbox and delete the input, the ...

Design an element that stretches across two navigation bars

Currently, I have implemented two Navbars on my website as shown in the image below: https://i.stack.imgur.com/4QmyW.png I am now looking to include a banner that clearly indicates that this site is a test site. In addition, I would like to incorporate a ...

Why do I keep encountering the error of an undefined variable? Where in my code am I making a mistake

I am struggling to troubleshoot an issue with creating a simple ease scroll effect using the jQuery plugins easing.js and jquery-1.11.0.min.js. $(function(){ //capturing all clicks $("a").click(function(){ // checking for # ...

Tips on utilizing CSS modules in React without changing class names

After starting to use css modules in my react project, I quickly realized the struggle of changing classnames to fit the requirements of css modules. For example, if we have a component using regular css: import React from 'react' import ". ...

Tips for testing a service in Angular using unit testing techniques

Within my service, I have a function that looks like this: exportPayGapDetails(filterObject: PayGapDetailFilter): void { const url = `${this.payGapDetailExportUrls[filterObject.type]}`; this.http .post<PollInitResponse>( `/adpi/rest/v2/s ...

Extracting information from within Ajax's Jsonp

How can I retrieve data from the Ajax function(result)? Why isn't this app working? Please assist me. function star(a) { var res; $.ajax({ url: 'https://api-metrica.yandex.com/analytics/v3/data/ga?end-date=today&ids=ga%3A35 ...

Adjusting the Connection header in a jQuery ajax request

I've been attempting to modify the Connection header using the code below, but so far, I haven't had any success jQuery.ajax({ url: URL, async: boolVariable, beforeSend: function(xhr) { xhr.setRequestHeader("Connection ...

What is the best way to target all elements sharing a common class?

Currently, I have a Boolean variable stored in a hidden input field. When the user is signed in, it's set to false; otherwise, it's set to true. I have download buttons that should link to a file for download. My goal is to hide these buttons an ...

Obtain every Scope within an AngularJS application

Is there a method to access all the Scopes within an AngularJS application? This would allow me to manage them at the same level and arrange them in a directive manner or order. Alternatively, is it possible to retrieve all the Scopes of the instances of ...