d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Google Sheets Macro Request > Topic
Add Reply New Topic New Poll
Member
Posts: 9,773
Joined: May 11 2007
Gold: 0.00
Apr 18 2017 05:15am
I like to think my request is simple but I have no idea how to make it.

Basically, I want to be able to specify a number of entries to be automatically added 2-3 minutes apart (random time stamps?)

Example: First entry on cell D2, 2:xx goes by then a second entry is added to D3, 2:xx goes by and D4.

I want the time stamps to be a random time between 120 and 180 seconds.

I want the entry to be simple, like the letter x.

I want to be able to specify the number of entries so that more aren't entered than I need.

tl;dr can this be done?
Member
Posts: 966
Joined: Apr 21 2017
Gold: 2,006.96
Apr 21 2017 07:27am
Should be fairly easy, you can define custom functions in the google sheets app and just run it - here's a quick example

Code
function addRows() {
var numToAdd = 10;
var minDelay = 1; // in seconds
var maxDelay = 3; // in seconds
for (i = 0; i < numToAdd; i++) {
var currDelay = Math.floor((Math.random() * maxDelay) + minDelay);
Utilities.sleep(currDelay*1000)
var sheet = SpreadsheetApp.getActiveSheet();
sheet.appendRow(['foo']);
}
}



You might have to modifiy it a little bit to pick the starting spot ( this starts at the next avail row )
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll