Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function onEdit()
- {
- highlightActualCells();
- }
- function onOpen()
- {
- highlightActualCells();
- }
- function highlightActualCells()
- {
- var ss = SpreadsheetApp.getActiveSpreadsheet();
- var actual = ss.getRangeByName( 'actual_highlight_range' );
- var category = ss.getRangeByName( 'category_highlight_range' );
- var bgColors = actual.getBackgroundColors();
- var actualVals = actual.getValues();
- var categoryVals = category.getValues();
- var newBgColors = bgColors;
- var white = 'white';
- var yellow = '#ffff88';
- var black = '#000000';
- for( var r = 0; r < bgColors.length; ++r )
- {
- var color = bgColors[r][0];
- if( color != black )
- {
- var actualVal = actualVals[r][0];
- var categoryVal = categoryVals[r][0];
- if( categoryVal > 0 && !actualVal )
- {
- newBgColors[r][0] = yellow;
- }
- else
- {
- newBgColors[r][0] = white;
- }
- }
- }
- actual.setBackgroundColors( newBgColors );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement