You need an Apps Script for this (under Tools > Script Editor). Here is how it could work (explanation below).
function loop() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName('Sheet1'); // name of your sheet
var data = ss.getSheetByName('data').getRange('A1:A20').getValues();
var output = [];
for (var i = 0; i < data.length; i++) {
sheet.getRange('B1').setValue(data[i][0]);
SpreadsheetApp.flush();
Utilities.sleep(10000);
if (sheet.getRange('B18').getValue() == 'Yes') {
output.push([data[i][0]]);
}
}
sheet.getRange(2, 12, output.length, 1).setValues(output);
}
The lines until for
are just setting up pointers to resources and grabbing data. In the loop, the value in B1 is set; the spreadsheet is flushed to make sure it really applies; and then the script waits 10 seconds (10000 milliseconds) for the financial data to arrive. You may decide to change this pause depending on your sheet's performance. If the value in B18 is Yes, the stock symbol is added to array "output". After the whole thing has ran, the output is placed in column L (column number 12).
To be able to run this function from the spreadsheet itself, add the function below to the script, which will create a menu item for it.
function onOpen() {
var menu = [{name: "Run a loop", functionName: "loop"}];
SpreadsheetApp.getActiveSpreadsheet().addMenu("Custom", menu);
}
(Another option is to use a clickable drawing).