I'm trying to make a custom function that will receive an array and a string as parameters, for example:
The script so far:
function VISITAS(CRM,CICLO) {
if(CRM.map){
return CRM.map(VISITAS);
}
else{
CICLO = (CICLO).toString();
return CICLO;
}
}
If i use the function like VISITAS(A1;D1) it works and return "CICLO" as needed but when using a range and a single cell, the values turns to "0" like the first image. The script so far is a test, the second parameter will be used in some conditional operations. How can i use a range and keep the value of the single cell?
EDIT: I'm sorry, i will provide the whole need.
This function will need to use the second parameter as a conditional to search and return data that is in another sheet and return this data for each row in the first array.
For example, i have a sheet with "CICLOS" from 1 to 7, i need it to return information of "CICLO 2" for example based on each line of the array
I have a scenario like this:
and i need to use the function one time per column using the column header and the "CLIENT" column as parameter, the output should be something like this:
With the first row below the header being the function



CRMwill be a 2D array andCICLOwill be a value. And, as @anton-dementiev mentioned below, whenVISITASis called in theCRM.map, it won't know theCICLOvalue. If you could provide more detail of what you're trying to do it would help.