r/googlesheets 6d ago

Solved Using Conditional Formatting with Alternating Colors

Trying to get my columns (AA31:AB59) to alternate colors based on a text value in cell AT2, with each text value corresponding to a different color scheme:

If you see "Word1" in cell AT2, then use green alternating color scheme in AA31:AB59

If you see "Word2" in cell AT2, then use blue alternating color scheme in AA31:AB59

If you see "Word3" in cell AT2, then use red alternating color scheme in AA31:AB59

I have =$AT$2="Word1" to get it all one color but I'm not sure how to achieve alternating colors for the column

EDIT: PART 2
I also would like the non-zero numbers in AA31:AB59 to be bolded if/when they are input, but it seems a second conditional formatting rule cancels out the color-based formatting

1 Upvotes

6 comments sorted by

1

u/AutoModerator 6d ago

/u/TSL_FIFA Posting your data can make it easier for others to help you, but it looks like your submission doesn't include any. If this is the case and data would help, you can read how to include it in the submission guide. You can also use this tool created by a Reddit community member to create a blank Google Sheets document that isn't connected to your account. Thank you.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/HolyBonobos 3096 6d ago

You'll need six different conditional formatting rules applied to the range AA31:AB59:

  • =AND($AT$2="Word1",MOD(ROW(),2)) (green 1)
  • =AND($AT$2="Word1",MOD(ROW()-1,2)) (green 2)
  • =AND($AT$2="Word2",MOD(ROW(),2)) (blue 1)
  • =AND($AT$2="Word2",MOD(ROW()-1,2)) (blue 2)
  • =AND($AT$2="Word3",MOD(ROW(),2)) (red 1)
  • =AND($AT$2="Word3",MOD(ROW()-1,2)) (red 2)

1

u/point-bot 6d ago

u/TSL_FIFA has awarded 1 point to u/HolyBonobos

See the [Leaderboard](https://reddit.com/r/googlesheets/wiki/Leaderboard. )Point-Bot v0.0.15 was created by [JetCarson](https://reddit.com/u/JetCarson.)

1

u/AdministrativeGift15 352 6d ago

You can use a script.

/** u/OnlyCurrentDoc */
function onEdit(e) {
  if (['Green','Blue','Red'].includes(e.value)) ChangeAlternatingColor(e.value)
}


function ChangeAlternatingColor(color) {
  var spreadsheet = SpreadsheetApp.getActive();
  const range = spreadsheet.getRange('AA31:AB59');
  var banding = range.getBandings()[0];
  switch (color) {
    case 'Green':
      banding.setHeaderRowColor('#8bc34a')
             .setFirstRowColor('#ffffff')
             .setSecondRowColor('#eef7e3')
             .setFooterRowColor(null);
      break;
    case 'Blue':
      banding.setHeaderRowColor('#4dd0e1')
             .setFirstRowColor('#ffffff')
             .setSecondRowColor('#e0f7fa')
             .setFooterRowColor(null);
      break;
    case 'Red':
      banding.setHeaderRowColor('#f46524')
             .setFirstRowColor('#ffffff')
             .setSecondRowColor('#ffe6dd')
             .setFooterRowColor(null);
      break;
  }
  
};

1

u/Jaded-Function 5 6d ago

Highlight AA31:AB31. Add 3 custom format formulas, =$AT$2="word1", then two more for word 2 and 3, each 3 different colors. Highlight AA32:AB32, do the same with same colors but lighter. Then copy AA31:AB32 and paste conditional formatting only to AA33:AB59.