need help, i try to read a cell in this fonction. I've tried 20 differents type of thing, i always have this error message when i run the focntion on my spreadsheet :
Message details :
Cannot convert
function getData() { Sheet = SS.getSheetByName("Technic"); Range = Sheet.getRange(4, 2); Data = Range.getValue(); }
to(class)
.
What wrong ?
function hideMyColumns()
{
var ss = SpreadsheetApp.getActive();
var sh = ss.getActiveSheet();
var vl = sh.getRange('A30').getValue();
var cols1 = [ function getData() {
Sheet = SS.getSheetByName('Technic');
Range = Sheet.getRange(4, 2);
Data = Range.getValue() }];
var cols2 = [4, 5, 7, 8, 10, 11,]
switch (vl)
{
case 1:
for (var i = 0; i < cols1.length; i++)
{
sh.hideColumns(cols1[i]);
}
break;
case 2:
for (var i = 0; i < cols2.length; i++)
{
sh.hideColumns(cols2[i]);
}
}
}
évolution of the situation :
ok, now the fonction is like this :
function hideMyColumns()
{
var ss=SpreadsheetApp.getActive();
var sh=ss.getActiveSheet();
var vl=sh.getRange('A30').getValue();
var cols1=[ function() {
Sheet = ss.getSheetByName('Technic');
Range = Sheet.getRange(2,4);
Data = Range.getValue();
return Data;
}()];
var cols2=[4,5,7,8,10,11,12,]
switch(vl)
{
case 1:
for(var i=0;i<cols1.length;i++)
{
sh.hideColumns(cols1[i]);
}
break;
case 2:
for(var i=0;i<cols2.length;i++)
{
sh.hideColumns(cols2[i]);
}
}
}
the context :
the spreadsheet have 2 sheet : "Main" and "Technic"
"Main" can have some columns hide by this fonction. In the sheet "Technic" you find a cell that contains a formula that returns:"2,3,4..." i try to use this formule like a variable in the fonction "hideMyColumns".
Under this i have another fonction more simple : unhideCols() of course. (work well!)