I would like to export the contents of the columns C & D (see red marking in the screenshot) as a text file using a button according to the scheme NYSE:GE,NYSE:BAC,... without breaks, spaces, etc.
The selection of the data should also be linked to certain conditions.
Example: Export all contents of columns C & D where the columns A, H, I and U (see blue marking in screenshot) contain something specific.
Ideally, it would be possible to set the conditions in the table using a drop-down selection, then retrieve the conditions in the code and trigger the export accordingly using a button.
Update: For my case I have changed the code from Cooper to the following. This works for me. Thanks to Cooper :-)
function cAndDtoCSV(filename) {
var filename=filename||'Watchlist.csv';
var ss=SpreadsheetApp.getActive();
var sh=ss.getActiveSheet();
var rg=sh.getDataRange();
var rg1 =ss.getRange(""); //Get range of conditions
var vA=rg.getValues();
var Cd1 = rg1.getCell().getValue(); //Get value of condition No.1
var Cd2 = rg1.getCell().getValue(); //Get value of condition No.2
var Cd3 = rg1.getCell().getValue(); //Get value of condition No.3
var csv="";
for(var i=0;i<vA.length;i++) {
if(vA[i][0]==Cd1 && vA[i][7]==Cd2 && vA[i][8]==Cd3) {
csv+=Utilities.formatString('%s,%s\r\n', vA[i][2],vA[i][3]);
}
}
var file=DriveApp.createFile(filename,csv,MimeType.CSV);
}