jeudi 25 février 2021

Using a function that'll allow me to bold specific cells in my data if it meets the requirements

I am currently trying to figure out how to make 4 numbers bold that is within a graph that has been provided to me. I need to make the two closest numbers to 5 (5.05 and 4.96) bold but they need to both be next to each other, so I believe I need to create a UI code to search along each row for this point, as soon as it passes 5.05 and hits 4.96, both of these values need to become bold.

Then I would need to create another bit of coding to then find the highest value and lowest value on the same row as the two previous values of 5.05 and 4.96.

In my coding below, this is my horrendous attempt of trying to start this but it obviously isn't working, plus it wouldn't allow me to use setBold() which is annoying. If anyone can help me, that would be amazing. I have left a link to my spreadsheet below so if you need a better idea of what I am trying to achieve, you can see it. If you do open it, it'll give you a message to activate the script, if you click no then you can still activate it by clicking on apply script in the menu bar. https://docs.google.com/spreadsheets/d/15MeTJLX2hmyJb6qN-9TJn7_2ik9mKZ8bCnv0CEyXiYI/edit?usp=sharing

function searchOutput() {

  var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  var dataSet = sheet.getRange("C3:W13").getValues();
  
  if (dataSet > 5){ sheet.getActiveCell().setFontColor("red").activate();}

}

Aucun commentaire:

Enregistrer un commentaire