-3

Unable to create a script. I would like to know if there is one that would allow me to color an entire row based on the value (a different color value) that I will find in the cells of column B.

For example, I want to color all rows that have the same value in the column B with the same color. For example If I have X in cell B2, B6, B8 The rows 1,6 and 8 in blue, if I have Y in B1, B5, B7 The rows 1,5,7 must be in green, etc. Only 10 possibilities with the conditional formatting, it's not enough for me.

  • 1
    You need to put in more effort in posting a question, JG. As it stands, it's not clear what you want. Read up in our help center to know more tour that. – Jacob Jan Tuinstra Feb 4 '14 at 17:51
0

Add a "on change call setRowColour()" trigger in the script editor (Resources>Current Project's Triggers) and add this in code.gs:

function setRowColour() {

    var sheet = SpreadsheetApp.getActive().getActiveSheet();

    // Get the colour of B2.   
    var colour = sheet.getRange('B2').getBackground();

    // Set the colour of row A.   
    var maxColumn = sheet.getMaxColumns();
    var range = sheet.getRange(1,1,1,maxColumn);
    range.setBackground(colour);    
}

I've made an example here.

  • Thank you very much but it's not quite what I want. Color all rows that have the same value in column B. Is this accurate? – user59595 Feb 8 '14 at 5:15
  • This dynamically sets the background colour of row A to the background colour of cell B2. Could you describe exactly what you are after? – andrewr Feb 8 '14 at 13:09
  • Thanks for your response. I want to color all rows that have the same value in the column B with the same color. For example If I have X in cell B2, B6, B8 The rows 1,6 et 8 in Blue, if I have Y in B1, B5, B7 The rows 1,5,7 must be in green etc..Only 10 possibilities with the conditionnal formating, it's not enough for me. JJ. – user59595 Feb 8 '14 at 21:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.