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

Google Apps Script Spreadsheet Auto Increment
Adding Button in Gmail for web users
Copy details from one sheet to another
Google Script Only Working When Logged In
no item with the given id could be found
setting advanced parameters for Jdbc.getConnection
Trigger on Google Docs doesn't work
Update (Overwrite) one Apps Script file with another Apps Script file using Apps Script Code
Google Apps Script - Chart Service: How to format numbers and dates
Google forms script to save responses into a csv (not excel) by default and email it as attachment
Can one receive a Google Cloud Messaging (GCM) message in a Google Apps Script
How to remove data validations?
Google Sheet script to import range a folder to one sheet
CopyTo: How to push data/copy a cell from one google spreadsheet to another google spreadsheet using google apps script?
Google Apps Script to clear ranges based on a single TRUE/FALSE cell in another sheet
Google sheet sorting a specific sheet

Categories

HOME
arrays
jsf
cluster-computing
sidekiq
xamarin.android
jsviews
freepascal
backup
flyway
adsense
user
desktop
ipfs
gatsby
netezza
alfresco-share
linq-to-sql
device-detection
tweets
tortoisegit
flexboxgrid
rails-activerecord
restfb
bcrypt
jflex
activepython
kong
owl-api
smart-mobile-studio
postgresql-9.2
swiftcharts
division
windows-10-iot-core
css-counter
hashcat
nunit-3.0
text-files
inkscape
xamarin.uitest
initializer
active-model-serializers
tic-tac-toe
viewgroup
php-ews
jgraph
maintenance
volume
emoticons
software-product-lines
aescryptoserviceprovider
bacnet
mongoskin
clob
uwp-maps
spring-lemon
selecteditem
concur
anti-cheat
group-concat
web-essentials
self-hosting
affix
zuora
js-cookie
apigee-baas
mptcp
web-component-tester
scrollspy
moai
rhel5
log4cplus
sid
joox
magic-numbers
android-json-rpc
lov
java.util.date
confusion-matrix
asp.net-mvc-scaffolding
vertical-rhythm
stagefright
threadx
localtime
justgage
grunt-contrib-compass
pascals-triangle
process-monitor
icsharpcode
mozart-mvc
blockingqueue
cosm
plone-funnelweb
isolatedstorage
nemerle
goliath
testunit
adobe-contribute
nvelocity
clause
loadui
swfloader
economics

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