Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.04 KB | None | 0 0
  1. function updateTotals(e) {
  2. if (e.changeType == "FORMAT") {
  3. SpreadsheetApp
  4. .getActiveSheet()
  5. .getRange('A1000')
  6. .setValue(Math.random());
  7. }
  8. }
  9.  
  10. function getBackgroundColor(rangeSpecification) {
  11. var sheet = SpreadsheetApp.getActiveSpreadsheet();
  12. return sheet.getRange(rangeSpecification).getBackgroundColor();
  13. }
  14.  
  15. function countCellsWithBackgroundColor(colorref, rangeSpecification) {
  16. var sheet = SpreadsheetApp.getActiveSpreadsheet();
  17. var range = sheet.getRange(rangeSpecification);
  18.  
  19. var x = 0;
  20.  
  21. for (var i = 1; i <= range.getNumRows(); i++) {
  22. for (var j = 1; j <= range.getNumColumns(); j++) {
  23.  
  24. var cell = range.getCell(i, j);
  25.  
  26. if(cell.getBackgroundColor() == SpreadsheetApp.getActiveSheet().getRange(colorref).getBackground())
  27. x++;
  28. }
  29. }
  30.  
  31. return x;
  32. }
  33.  
  34. =countCellsWithBackgroundColor("D4";"E5:AX5"; A1000)
  35. =countCellsWithBackgroundColor("D4";"E6:AX6"; A1000)
  36. =countCellsWithBackgroundColor("D4";"E7:AX7"; A1000)
  37. =countCellsWithBackgroundColor("D4";"E8:AX8"; A1000)
  38. =countCellsWithBackgroundColor("D4";"E9:AX9"; A1000)
  39. =countCellsWithBackgroundColor("D4";"E10:AX10"; A1000)
  40. =countCellsWithBackgroundColor("D4";"E11:AX11"; A1000)
  41. =countCellsWithBackgroundColor("D4";"E12:AX12"; A1000)
  42. =countCellsWithBackgroundColor("D4";"E13:AX13"; A1000)
  43. =countCellsWithBackgroundColor("D4";"E14:AX14"; A1000)
  44. =countCellsWithBackgroundColor("D4";"E15:AX15"; A1000)
  45. =countCellsWithBackgroundColor("D4";"E16:AX16"; A1000)
  46. =countCellsWithBackgroundColor("D4";"E17:AX17"; A1000)
  47. =countCellsWithBackgroundColor("D4";"E18:AX18"; A1000)
  48. =countCellsWithBackgroundColor("D4";"E19:AX19"; A1000)
  49. =countCellsWithBackgroundColor("D4";"E20:AX20"; A1000)
  50. =countCellsWithBackgroundColor("D4";"E21:AX21"; A1000)
  51. =countCellsWithBackgroundColor("D4";"E22:AX22"; A1000)
  52. =countCellsWithBackgroundColor("D4";"E23:AX23"; A1000)
  53. =countCellsWithBackgroundColor("D4";"E24:AX24"; A1000)
  54. =countCellsWithBackgroundColor("D4";"E25:AX25"; A1000)
  55. =countCellsWithBackgroundColor("D4";"E26:AX26"; A1000)
  56. =countCellsWithBackgroundColor("D4";"E27:AX27"; A1000)
  57. =countCellsWithBackgroundColor("D4";"E28:AX28"; A1000)
  58. =countCellsWithBackgroundColor("D4";"E29:AX29"; A1000)
  59. =countCellsWithBackgroundColor("D4";"E30:AX30"; A1000)
  60. =countCellsWithBackgroundColor("D4";"E31:AX31"; A1000)
  61. =countCellsWithBackgroundColor("D4";"E32:AX32"; A1000)
  62. =countCellsWithBackgroundColor("D4";"E33:AX33"; A1000)
  63. =countCellsWithBackgroundColor("D4";"E34:AX34"; A1000)
  64. =countCellsWithBackgroundColor("D4";"E35:AX35"; A1000)
  65. =countCellsWithBackgroundColor("D4";"E36:AX36"; A1000)
  66. =countCellsWithBackgroundColor("D4";"E37:AX37"; A1000)
  67. =countCellsWithBackgroundColor("D4";"E38:AX38"; A1000)
  68. =countCellsWithBackgroundColor("D4";"E39:AX39"; A1000)
  69. =countCellsWithBackgroundColor("D4";"E40:AX40"; A1000)
  70. =countCellsWithBackgroundColor("D4";"E41:AX41"; A1000)
  71. =countCellsWithBackgroundColor("D4";"E42:AX42"; A1000)
  72. =countCellsWithBackgroundColor("D4";"E43:AX43"; A1000)
  73. =countCellsWithBackgroundColor("D4";"E44:AX44"; A1000)
  74. =countCellsWithBackgroundColor("D4";"E45:AX45"; A1000)
  75. =countCellsWithBackgroundColor("D4";"E46:AX46"; A1000)
  76. =countCellsWithBackgroundColor("D4";"E47:AX47"; A1000)
  77. =countCellsWithBackgroundColor("D4";"E48:AX48"; A1000)
  78. =countCellsWithBackgroundColor("D4";"E49:AX49"; A1000)
  79. =countCellsWithBackgroundColor("D4";"E50:AX50"; A1000)
  80. =countCellsWithBackgroundColor("D4";"E51:AX51"; A1000)
  81. =countCellsWithBackgroundColor("D4";"E52:AX52"; A1000)
  82. =countCellsWithBackgroundColor("D4";"E53:AX53"; A1000)
  83. =countCellsWithBackgroundColor("D4";"E54:AX54"; A1000)
  84. =countCellsWithBackgroundColor("D4";"E55:AX55"; A1000)
  85. =countCellsWithBackgroundColor("D4";"E56:AX56"; A1000)
  86. =countCellsWithBackgroundColor("D4";"E57:AX57"; A1000)
  87. =countCellsWithBackgroundColor("D4";"E58:AX58"; A1000)
  88. =countCellsWithBackgroundColor("D4";"E59:AX59"; A1000)
  89. =countCellsWithBackgroundColor("D4";"E60:AX60"; A1000)
  90. =countCellsWithBackgroundColor("D4";"E61:AX61"; A1000)
  91. =countCellsWithBackgroundColor("D4";"E62:AX62"; A1000)
  92. =countCellsWithBackgroundColor("D4";"E63:AX63"; A1000)
  93. =countCellsWithBackgroundColor("D4";"E64:AX64"; A1000)
  94. =countCellsWithBackgroundColor("D4";"E65:AX65"; A1000)
  95. =countCellsWithBackgroundColor("D4";"E66:AX66"; A1000)
  96. =countCellsWithBackgroundColor("D4";"E67:AX67"; A1000)
  97. =countCellsWithBackgroundColor("D4";"E68:AX68"; A1000)
  98. =countCellsWithBackgroundColor("D4";"E69:AX69"; A1000)
  99. =countCellsWithBackgroundColor("D4";"E70:AX70"; A1000)
  100. =countCellsWithBackgroundColor("D4";"E71:AX71"; A1000)
  101. =countCellsWithBackgroundColor("D4";"E72:AX72"; A1000)
  102. =countCellsWithBackgroundColor("D4";"E73:AX73"; A1000)
  103. =countCellsWithBackgroundColor("D4";"E74:AX74"; A1000)
  104. =countCellsWithBackgroundColor("D4";"E75:AX75"; A1000)
  105. =countCellsWithBackgroundColor("D4";"E76:AX76"; A1000)
  106. =countCellsWithBackgroundColor("D4";"E77:AX77"; A1000)
  107. =countCellsWithBackgroundColor("D4";"E78:AX78"; A1000)
  108. =countCellsWithBackgroundColor("D4";"E79:AX79"; A1000)
  109. =countCellsWithBackgroundColor("D4";"E80:AX80"; A1000)
  110. =countCellsWithBackgroundColor("D4";"E81:AX81"; A1000)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement