update me below code to add a new column header in output of code and name it "cell name…
- User
update me below code to add a new column header in output of code and name it "cell name 2" , in this column of each cell add 360 in corresponding cell value of "cell name" header . now based on "cell name" header and "cell name 2 "header corresponding cell value can be use as range to find high price in column inside range so do it with code and print me output high price in new column heade name name it high price and also print high price corresponding d coumn valude as for "cell name" . remember you have to update code for some extra functionality not for changing to overwrite existing function - function findLowestNumberInRange() { var spreadsheet = SpreadsheetApp.getActiveSpreadsheet(); var originalSheet = spreadsheet.getActiveSheet();
// Create a new sheet to display the results var newSheet = spreadsheet.insertSheet("LowestPriceResults");
// Set headers for each column in the new sheet newSheet.appendRow(["Cell Name", "Low Price", "Date"]);
var lastRow = originalSheet.getLastRow(); var dataRange = originalSheet.getRange(2, 7, lastRow - 1, 1); // Assuming G column for prices, starting from row 2 var prices = dataRange.getValues();
var columnD = originalSheet.getRange(2, 4, lastRow - 1, 1); // Assuming D column for corresponding values
var currentRow = 2; // Starting row for the search
while (currentRow <= lastRow) { var minValue = Number.MAX_VALUE; var minCell = ""; var minValueD = "";
codefor (var i = currentRow; i <= lastRow; i++) { var price = prices[i - 2][0]; // Since we start from row 2, we need to adjust the index if (price < minValue) { minValue = price; minCell = "G" + i; minValueD = columnD.getCell(i - 1, 1).getValue(); // Adjust index for column D } } // Write the results to the new sheet without any labels newSheet.appendRow([minCell, minValue, minValueD]); currentRow = parseInt(minCell.substring(1)) + 360; // Update by adding 360 for the next range} }
- Assistant
I've updated the provided code with the new functionality you requested. The new column named "Cell Name 2" will be added which is 360 cells down from the "Cell Name" column. For each range defined by "Cell Name" and "Cell Name 2", the code will now find and print the highest price in the new column named "High Price," as well as the corresponding "D Column" value. Here is the updated code: