google-apps-script


Script wont work on new sheets/spreadsheets


I have been using this script for months, but now i wanted to add it to another sheets or spreadsheet and its not working, on old sheets where it was added moths ago it works fine.
Script is for hiding empty rows and showing rows that has values.
Maybe someone have any idea what to change in script so that it works again?
function hiderows() {
var ss = SpreadsheetApp.openById('1YoInjxlCeBPZP0HlEW0HSYBkdMCGtRaeJFylCQNXnMM');
sheets = ["Lapa1"]
for (var s = 0; s < sheets.length; s++) {
var sh = ss.getSheetByName(sheets[s]);
var firstRow = 1;
var firstCol = 1;
var data = sh.getDataRange().getValues();
var show = null, map = [], index, flag;
for (var i = firstRow - 1, length = data.length; i < length; i++) {
flag = false;
for (var j = firstCol - 1, width = data[0].length; j < width; j++) {
if (data[i][j] ) {
flag = true;
break;
}
}
if (show === flag) {
map[index].rows++;
} else {
index = i + 1;
show = flag;
map[index] = {rows: 1, show: show};
}
}
for (
var i in map) {
if (map[i].show) {
sh.showRows(i, map[i].rows);
} else {
sh.hideRows(i, map[i].rows);
}
}
}
}

Related Links

ocr images from list of urls and store the results in spreadsheet
Get a copy of Body to make a “preview” window
How to copy a row from a sheet and paste multiple versions with minor changes to another sheet
Change GoogleApps script to get from separate sheet
Google Apps Script to count number of emails sent/received yesterday, that has a certain label, then save # daily to spreadsheet
Google Calendar Appointment Slot : Custom Functionality
Change chart properties in Google Slides API
consolidate specific row values from different sheets
Google Script does not see txt attachment in gmail message
I can't get values for docs:num_docs using CustomerUsageReport api
Insert new row in a Google Sheet and copy a pre-formatted row into it
Google Form :How google form automatically choose the radio button depend on another pair which surveyee chose to have sum of 1a and 1b equal to 5
function with parameter for addItem in spreadsheet menu using app script
Google sheets script onEdit of form response clear cells
onEdit trigger e.range only one cell instead of whole selection
Google Spreadheet Script to save and load data to another sheet

Categories

HOME
plsql
sass
answer-set-programming
csvhelper
azureservicebus
laravel-4
ios10
histogrammar
bro
shader
contact-form-7
ssr
hashicorp-vault
game-maker-studio-1.4
dryioc
automata
react-leaflet
bootstrap-popover
yeoman-generator
eclipselink
distance
koa
raphael
uiautomator
iup
nmf
fabric
skmaps
frp
helper
data-conversion
superscript
getjson
protobuf-net
entity-system
read-write
skygear
pljson
google-guava-cache
oscommerce
npm-publish
silverlight-3.0
active-model-serializers
flex4.5
intellij-idea-2016
google-account
median
ttcn
azure-availability-set
taskmanager
chunked-encoding
amazon-machine-learning
livefyre
broadcast
ticker
android-bitmap
httplib2
redux-router
sqlexception
festival
restivejs
pdfkit
picasa
debugdiag
angularjs-ng-pattern
freetype2
metalsmith
console-redirect
selecteditem
anti-cheat
cmocka
android-recyclerview
test-class
throughput
jenkins-scriptler
app.xaml
twython
connection-reset
stream-framework
google-hadoop
web-component-tester
httpie
jcr-sql2
proximity
tcpreplay
hidden-field
mbox
sqljdbc
nservicebus4
google-closure-library
sharpmap
resgen
mpmovieplayer
redirectstandardoutput
wcf-web-api
electronic-signature
newsstand-kit
curljs
executable-format
paintcomponent
opengl-es-lighting
associative
smooth
pureftpd
file-encodings
clients
front-controller
gears
self-reference

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App