Multiple Issues with Google Sheets Scripts (JavaScript) - Overclock.net - An Overclocking Community

Forum Jump: 

Multiple Issues with Google Sheets Scripts (JavaScript)

 
Thread Tools
post #1 of 1 (permalink) Old 12-06-2018, 09:25 AM - Thread Starter
Retired Staff
 
XiCynx's Avatar
 
Join Date: Oct 2007
Location: Elyria, Ohio
Posts: 2,309
Rep: 128 (Unique: 111)
Multiple Issues with Google Sheets Scripts (JavaScript)

Hello all, NEEDLES TO SAY, I am very new to this, but trying my hardest to figure all this out. I have a script right now which actively removes all empty rows from an entire workbook. But I'm hoping someone can assist is narrowing this down to a single sheet within that workbook.
Code:
function removeEmptyRows() {
    SpreadsheetApp.getActive()
        .getSheets()
        .forEach(function (s) {
            c = 0;
            s.getRange(1, 1, s.getMaxRows(), s.getMaxColumns())
                .getValues()
                .forEach(function (r, j) {
                    if (r.toString()
                        .replace(/,/g, "")
                        .length == 0) {
                        s.deleteRow((j += 1) - c)
                        c += 1;
                    }
                })
        })
}
Ideally I would like for this to remove only blank rows on one sheet within my workbook called 'Racing Results'. The reason I'm need this, is due to how the spreadsheet is setup and having multiple rows merged together. So when I copy these results over to a different sheet, there are gaps between them and I'd like them removed. Here is the script I'm using to copy the data to another sheet.
Code:
function Copy() {

 var sss = SpreadsheetApp.openById('18cl69Id4saI455wk__-PhvfxXZa7iWlQpoiRKqBz6bU');
 var ss = sss.getSheetByName('Score Card');
 var range = ss.getRange('A32:E36');
 var data = range.getValues();
 var tss = SpreadsheetApp.openById('18cl69Id4saI455wk__-PhvfxXZa7iWlQpoiRKqBz6bU');
 var ts = tss.getSheetByName('Race Results');

 ts.getRange(ts.getLastRow()+1, 1, data.length, data[0].length).setValues(data);

}
If not to throw one final monkey wrench into this colossal mess, I have been attempting to copy two different cell ranges within the same script and I feel like this isn't possible because only the latter one gets copied and the initial one is discarded. Here is the other copy script I am using which runs before the one above this.
Code:
 function Copy() {
  
var sss = SpreadsheetApp.openById('18cl69Id4saI455wk__-PhvfxXZa7iWlQpoiRKqBz6bU');
 var ss = sss.getSheetByName('Score Card');
 var range = ss.getRange('A1:A1');
 var data = range.getValues();
 var tss = SpreadsheetApp.openById('18cl69Id4saI455wk__-PhvfxXZa7iWlQpoiRKqBz6bU');
 var ts = tss.getSheetByName('Race Results');

 ts.getRange(ts.getLastRow()+1, 1, data.length, data[0].length).setValues(data);
  
}


In a perfect world, what I'm trying to get setup is the following. Above is a screenshot of the scorecard we are using. I am wanting to copy the Current Date (A1) to the 'Racing Results' sheet, then I want to copy the final score with the team names (A32:E36) and move them to the 'Racing Results' sheet right under it. Once that has been done, I want to remove the empty rows between the results because as of right now this is how it looks when copying over. (see image below)



Thanks in advance to anyone who is able to assist with any of this in any way shape or form.

Overclock What!? (Click to show)
Quote:
Originally Posted by 10acjed 
I get 7 trillion frames per nanosecond in BC2
Quote:
Originally Posted by Ecchi-BANZAII!!! 
Did you OC the floppy drive?wink.gif
Quote:
Originally Posted by WaterMelnKidd 
He must have, I remember seeing this performance increase after overlocking my memory card reader to allow me to dual boot / play BFBC2 off a 4GB MicroSD.
Quote:
Originally Posted by jellis142 
How did you fit BC2 on a 4Gb drive?!?!?! eek.gif
Quote:
Originally Posted by WaterMelnKidd 
I just simply overclocked it to 40GB.
Contact Details (Click to show)
Google Talk: [email protected]
Twitter: XiCynx


XiCynx is offline  
Sponsored Links
Advertisement
 
Reply

Quick Reply
Message:
Options

Register Now

In order to be able to post messages on the Overclock.net - An Overclocking Community forums, you must first register.
Please enter your desired user name, your email address and other required details in the form below.
User Name:
If you do not want to register, fill this field only and the name will be used as user name for your post.
Password
Please enter a password for your user account. Note that passwords are case-sensitive.
Password:
Confirm Password:
Email Address
Please enter a valid email address for yourself.
Email Address:

Log-in



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Show Printable Version Show Printable Version
Email this Page Email this Page


Forum Jump: 

Posting Rules  
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off