Note: The other languages of the website are Google-translated. Back to English
Oturum aç  \/ 
x
or
x
Kaydol  \/ 
x

or

Google sayfasındaki hücre rengine göre hücreler nasıl sayılır veya toplanır?

Gösterilen aşağıdaki ekran görüntüsü gibi sonucu almak için belirli hücre arka plan rengine göre hücre değerlerini sayma veya toplama. Bu yazıda, bu görevin nasıl çözüleceğini Google sayfası ve Microsoft Excel'de anlatacağım.

Google sayfasındaki komut dosyasıyla hücre rengine göre hücre değerlerini sayın

Google sayfasındaki komut dosyasıyla hücre rengine dayalı olarak hücre değerlerini toplama

Microsoft Excel'de Kutools for Excel ile hücre rengindeki hücre değerlerini sayın veya toplayın


Google sayfasındaki komut dosyasıyla hücre rengine göre hücre değerlerini sayın

Aşağıdaki komut dosyası, belirli hücre rengine göre hücre değerlerini saymanıza yardımcı olabilir, lütfen şu şekilde yapın:

1. tıklayın Araçlar > Komut dosyası düzenleyici, ekran görüntüsüne bakın:

2. Açılan proje penceresinde, fileto > yeni > Komut dosyaları bir kod penceresi açmak için ekran görüntüsüne bakın:

3. Ve istem kutusuna lütfen bu komut dosyası kodu için bir ad girin, ekran görüntüsüne bakın:

4. tıklayın OK ve ardından orijinal kodu kod modülüne değiştirmek için aşağıdaki kodu kopyalayıp yapıştırın, ekran görüntüsüne bakın:

function countColoredCells(countRange,colorRef) {
  var activeRg = SpreadsheetApp.getActiveRange();
  var activeSht = SpreadsheetApp.getActiveSheet();
  var activeformula = activeRg.getFormula();
  var countRangeAddress = activeformula.match(/\((.*)\,/).pop().trim();
  var backGrounds = activeSht.getRange(countRangeAddress).getBackgrounds();
  var colorRefAddress = activeformula.match(/\,(.*)\)/).pop().trim();
  var BackGround = activeSht.getRange(colorRefAddress).getBackground();
  var countCells = 0;
  for (var i = 0; i < backGrounds.length; i++)
    for (var k = 0; k < backGrounds[i].length; k++)
      if ( backGrounds[i][k] == BackGround )
        countCells = countCells + 1;
  return countCells;
};

5. Sonra bu komut dosyası kodunu kaydedin ve sayfaya geri dönün, şu formülü girin: = renkli hücreler (A1: E11, A1) boş bir hücreye girin ve ardından Keşfet hesaplanan sonucu almak için anahtar. Ekran görüntüsüne bakın:

not: Bu formülde: A1: E11 kullanmak istediğiniz veri aralığı, A1 saymak istediğiniz belirli bir renkle dolu hücredir.

6. Diğer belirli renkli hücreleri saymak için yukarıdaki formülü tekrarlayın.


Google sayfasındaki komut dosyasıyla hücre rengine dayalı olarak hücre değerlerini toplama

Hücre değerlerini belirli bir hücre rengiyle toplamak için lütfen aşağıdaki kod kodunu uygulayın.

1. Le Marchê'nin deri koleksiyonlarını görmek için Araçlar > Komut dosyası düzenleyici proje penceresine gitmek için tıklayın fileto > yeni > Komut dosyaları başka bir yeni kod modülü eklemek için, daha sonra komut kutusuna lütfen bu komut dosyası için bir ad yazın, ekran görüntüsüne bakın:

2. tıklayın OK ve açılan kod modülünde, orijinal kodu değiştirmek için aşağıdaki kod kodunu kopyalayıp yapıştırın, ekran görüntüsüne bakın:

function sumColoredCells(sumRange,colorRef) {
  var activeRg = SpreadsheetApp.getActiveRange();
  var activeSht = SpreadsheetApp.getActiveSheet();
  var activeformula = activeRg.getFormula();
  var countRangeAddress = activeformula.match(/\((.*)\,/).pop().trim();
  var backGrounds = activeSht.getRange(countRangeAddress).getBackgrounds();
  var sumValues = activeSht.getRange(countRangeAddress).getValues();  
  var colorRefAddress = activeformula.match(/\,(.*)\)/).pop().trim();
  var BackGround = activeSht.getRange(colorRefAddress).getBackground();
  var totalValue = 0;
  for (var i = 0; i < backGrounds.length; i++)
    for (var k = 0; k < backGrounds[i].length; k++)
      if ( backGrounds[i][k] == BackGround )
        if ((typeof sumValues[i][k]) == 'number')
          totalValue = totalValue + (sumValues[i][k]);
  return totalValue;
};

3. Ve sonra bu kodu kaydedin, sayfaya dönün ve şu formülü girin: = renkli hücreler (A1: E11, A1) boş bir hücreye girin ve Keşfet hesaplanan sonucu almak için anahtar, ekran görüntüsüne bakın:

not: Bu formülde: A1: E11 kullanmak istediğiniz veri aralığı, A1 özetlemek istediğiniz belirli bir arka plan rengine sahip hücredir.

4. Ardından, diğer belirli renkli hücreleri toplamak için yukarıdaki formülü tekrarlayabilirsiniz.


Microsoft Excel'de Kutools for Excel ile hücre rengindeki hücre değerlerini sayın veya toplayın

Microsoft Excel'de, hücre değerlerini belirli hücre rengine göre saymak veya toplamak için, Kutools for Excel'S Renge Göre Say yardımcı program bu görevi olabildiğince çabuk bitirmenize yardımcı olabilir.

Kutools for Excel : 300'den fazla kullanışlı Excel eklentisi ile 30 günde sınırlama olmaksızın ücretsiz deneyin. 

Kurduktan sonra Kutools for Excellütfen şunu yapın:

1. Hücre rengine göre saymak veya toplamak istediğiniz aralıktaki hücreleri seçin ve ardından Kutools Artı > Renge Göre Say, ekran görüntüsüne bakın:

2. In Renge Göre Say diyalog kutusunu seçiniz Standart biçimlendirme itibaren Renk yöntemi açılır listeyi seçin ve ardından Arka fon itibaren Sayım türü açılır, ekran görüntüsüne bakın:

3. Sonra tıklayın Rapor oluştur düğmesi ve hesaplanan sonuçları içeren yeni çalışma sayfası bir kerede oluşturulur, ekran görüntüsüne bakın:

not: Bu güçlü özellikle, hücre değerlerini koşullu biçimlendirmeye veya yazı tipi rengine göre de hesaplayabilirsiniz.

İndir'i tıklayın ve Kutools for Excel'i Şimdi ücretsiz deneyin!


En İyi Ofis Üretkenliği Araçları

Kutools for Excel Sorunlarınızın Çoğunu Çözer ve Verimliliğinizi% 80 Artırır

  • Yeniden: Hızlıca yerleştirin karmaşık formüller, grafikler ve daha önce kullandığınız her şey; Hücreleri Şifrele şifre ile; Posta Listesi Oluşturun ve e-posta gönder ...
  • Süper Formül Çubuğu (birden çok metin ve formül satırını kolayca düzenleyin); Okuma Düzeni (çok sayıda hücreyi kolayca okuyun ve düzenleyin); Filtrelenmiş Aralığa Yapıştır...
  • Hücreleri / Satırları / Sütunları Birleştirme Veri kaybetmeden; Bölünmüş Hücre İçeriği; Yinelenen Satırları / Sütunları Birleştirme... Yinelenen Hücreleri Önleyin; Aralıkları Karşılaştır...
  • Yinelenen veya Benzersiz'i seçin Satırlar; Boş Satırları Seçin (tüm hücreler boştur); Süper Bul ve Bulanık Bul Birçok Çalışma Kitabında; Rastgele Seçim ...
  • Tam kopya Formül referansını değiştirmeden Birden Çok Hücre; Otomatik Referans Oluştur Birden Çok Sayfaya; Madde İşaretleri Ekle, Onay Kutuları ve daha fazlası ...
  • Metni Çıkar, Metin Ekle, Konuma Göre Kaldır, Alanı Kaldır; Sayfalama Alt Toplamları Oluşturma ve Yazdırma; Hücre İçeriği ve Yorumları Arasında Dönüştür...
  • Süper Filtre (filtre şemalarını kaydedin ve diğer sayfalara uygulayın); Gelişmiş Sıralama ay / hafta / gün, sıklık ve daha fazlasına göre; Özel Filtre kalın, italik ...
  • Çalışma Kitaplarını ve Çalışma Sayfalarını Birleştirin; Tabloları anahtar sütunlara göre birleştirin; Verileri Birden Çok Sayfaya Bölme; Toplu dönüştürme xls, xlsx ve PDF...
  • 300'den fazla güçlü özellik. Office / Excel 2007-2019 ve 365'i destekler. Tüm dilleri destekler. Kuruluşunuzda veya kuruluşunuzda kolay dağıtım. Tam özellikli 30 günlük ücretsiz deneme. 60 günlük para iade garantisi.
kte sekmesi 201905

Office Tab, Office'e Sekmeli Arayüz Getirir ve İşinizi Çok Daha Kolay Hale Getirir

  • Word, Excel, PowerPoint'te sekmeli düzenlemeyi ve okumayı etkinleştirin, Publisher, Access, Visio ve Project.
  • Yeni pencereler yerine aynı pencerenin yeni sekmelerinde birden çok belge açın ve oluşturun.
  • Üretkenliğinizi% 50 artırır ve her gün sizin için yüzlerce fare tıklamasını azaltır!
ofis tabanı
Say something here...
symbols left.
You are guest
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Nguyen Thuan · 13 days ago
    hoạt động 100%:

    function countColoredCells(countRange;colorRef) {
    var activeRg = SpreadsheetApp.getActiveRange();
    var activeSht = SpreadsheetApp.getActiveSheet();
    var activeformula = activeRg.getFormula();
    var countRangeAddress = activeformula.match(/\((.*)\;/).pop().trim();
    var backGrounds = activeSht.getRange(countRangeAddress).getBackgrounds();
    var colorRefAddress = activeformula.match(/\;(.*)\)/).pop().trim();
    var BackGround = activeSht.getRange(colorRefAddress).getBackground();
    var countCells = 0;
    for (var i = 0; i < backGrounds.length; i++)
    for (var k = 0; k < backGrounds[i].length; k++)
    if ( backGrounds[i][k] == BackGround )
    countCells = countCells + 1;
    return countCells;
    };

    Nhập
    =countColoredCells(A1: E11, A1)

    note: thay tất cả "," bằng ";" trong mã

  • To post as a guest, your comment is unpublished.
    Fabricio · 2 months ago
    Hello everyone.
    I need a little help here.. I used the formula and worked fine, but when I change the color of some cells the number result of the formula don´t update automatically.. I always need to copy and paste the formula again to update. Has someone resolved this!?
    • To post as a guest, your comment is unpublished.
      nhmelevskiy · 2 months ago
      The formula does not work when the color changes, only when the cell values change. Just change the value inside the cell, not the color.

      For convenience, I did this:
      I included a column with a checkbox in the required range, and when the value in it changes, my formula is updated. It's like an on / off switch.
    • To post as a guest, your comment is unpublished.
      Nikita · 2 months ago
      The formula does not work when the color changes, only when the cell values change. Just change the value inside the cell, not the color.

      For convenience, I did this:
      I included a column with a checkbox in the required range, and when the value in it changes, my formula is updated. It's like an on / off switch.
  • To post as a guest, your comment is unpublished.
    Anna · 3 months ago
    Works for code:
    function countColoredCells(countRange, colorRef, unUsed) {
    var backGrounds = SpreadsheetApp.getActiveSheet().getRange(countRange).getBackgrounds();
    var backGround = SpreadsheetApp.getActiveSheet().getRange(colorRef).getBackground();
    var countCells = 0;
    for (var i = 0; i < backGrounds.length; ++i)
    for (var k = 0; k < backGrounds[i].length; ++k)
    if ( backGrounds[i][k] == backGround )
    ++countCells;
    return countCells;
    }

    function onEdit(e)
    {
    SpreadsheetApp.getActiveSheet().getRange('A1').setValue(Math.random());
    }


    but You neet do call the function like that:
    =countColoredCells("C6:W21";"E2";$A$1)

    where
    "C6-W21" is the area analysed
    "E2" is the model cell
    $A$1 - don't know why this is, but it writes a random number to the cell A1
    • To post as a guest, your comment is unpublished.
      nhmelevskiy · 2 months ago
      "$A$1 - don't know why this is, but it writes a random number to the cell A1"

      $A$1 is a cell in which calculations are made, a buffer.

      Please note that the cell will be displayed in the entire workbook, in all tabs. I have not yet learned how to bind it to only one tab. Email me if you solve this.
  • To post as a guest, your comment is unpublished.
    chan · 6 months ago
    thanks, :)
  • To post as a guest, your comment is unpublished.
    Hawjin · 7 months ago
    Autoupdate of the formula

    A tip is to create a script that inserts a row in the range and then removes the same row again. And then set up a time-based trigger for the function =)
  • To post as a guest, your comment is unpublished.
    guest · 7 months ago
    it errors for me :/
  • To post as a guest, your comment is unpublished.
    Davide · 1 years ago
    Thank you so much for these scripts, Truly appreciated, it's not to get something that works out of the box.

    Question how would I go about modifying the values sum script to pull part of a cell, for exammple a cell that contains the following:
    909 & 1909
    {1 of 2}
    SM & M (3.5)

    How would I go about pulling the "3.5" in parenthesis and sum that numerical value coming out multiple cells of the same color. I know how to pull the value out in google sheets but can't figure out how to combine it with the cell color script.

    Thank you.

  • To post as a guest, your comment is unpublished.
    Richard · 1 years ago
    Has anyone updated this for the Sum colored cells? i'm ok with copying and pasting the forumla for now but it would be nice if i highlighted more cells, it would add those cells to the total automatically. I'm a newb when it comes to reading code, i tried a few things based on all the comments but alas, i'm still new.

    Thanks,

  • To post as a guest, your comment is unpublished.
    rodrigosromaro@gmail.com · 1 years ago
    PLEASE SOMEONE COULD HELP ME ?
    I WAS LOOKING FOR HOW TO SOLVE THAT A MONTH AT LEAST. I TRIED MANY THINGS, CHANGED COMMAS .... AND NOTHING SOLVE THAT...


    ------------- TypeError: Cannot call method "pop" of null. (line 5, file "SumByColor") -----------------

    //*ORIGINAL - var countRangeAddress = activeformula.match(/\((.*)\,/).pop().trim();
    //*I TRYING - var countRangeAddress = activeformula.match(/\((.*)\;/).pop().trim();
    //*ORIGINAL - var colorRefAddress = activeformula.match(/\,(.*)\)/).pop().trim();
    //*I TRYING - var colorRefAddress = activeformula.match(/\;(.*)\)/).pop().trim();

    some charitable soul please help me, I don't have much programming ... #sad
  • To post as a guest, your comment is unpublished.
    Andrew · 1 years ago
    HI, Brian! Thank's for your effort to give us the updated code. The auto update feature doesn't works for me. It doesn't write a new random number in A1 automatically, s i have to do it manually to get refresh. Is it as planed or Do i miss something? Thanks for your reply.
    • To post as a guest, your comment is unpublished.
      Milan · 8 months ago
      I have the same proble. Am I missing anything?
  • To post as a guest, your comment is unpublished.
    netman · 1 years ago
    hi Brian, I have tried to use the updated version. It is improved but still not always update after change color.
    is it possible to add a command to refresh the 'A1' value timely. thanks.
  • To post as a guest, your comment is unpublished.
    Brian · 1 years ago
    Hi all, I wanted to give you an updated version of how to count the number of cells that are a given color. This version solves a couple of issues:

    1. The count not updating when the doc changes and
    2. Errors from adding another parameter to the function


    // Unsed third argument
    function countColoredCells(countRange,colorRef,unUsed) {
    var activeRg = SpreadsheetApp.getActiveRange();
    var activeSht = SpreadsheetApp.getActiveSheet();
    var activeformula = activeRg.getFormula();
    // The regex matches the parentheses as an array, gets the arguments as a string,
    // then splits the arguments on the comma into another array
    var arrayOfArguments = activeformula.match(/\((.*)\)/).pop().trim().split(',');
    // Get the first argument which is the range
    var countRangeAddress = arrayOfArguments[0];
    // Get the second argument, which is the reference color
    var colorRefAddress = arrayOfArguments[1];
    var backGrounds = activeSht.getRange(countRangeAddress).getBackgrounds();
    var BackGround = activeSht.getRange(colorRefAddress).getBackground();
    var countCells = 0;
    for (var i = 0; i < backGrounds.length; i++)
    for (var k = 0; k < backGrounds[i].length; k++)
    if ( backGrounds[i][k] == BackGround )
    countCells = countCells + 1;
    return countCells;
    };

    // Writes a random number to A1
    function onEdit(e)
    {
    SpreadsheetApp.getActiveSheet().getRange('A1').setValue(Math.random());
    }


    Usage: =countColoredCells(B2:E22,A28,$A$1)
    • To post as a guest, your comment is unpublished.
      Lenore · 1 years ago
      Do we paste all of this to replace the original code?
      • To post as a guest, your comment is unpublished.
        skyyang · 1 years ago
        Hello, Lenore,
        The Brian's code is worked well to auto update the result when you change the cell color, please apply it.
        Yes, you should pasting all of the above code to replace the original one.
  • To post as a guest, your comment is unpublished.
    La · 2 years ago
    TypeError: Não é possível chamar o método "pop" de null. (linha 5, arquivo "sumbycolor")

    How can I fix this error? Thank you
  • To post as a guest, your comment is unpublished.
    Nataly · 2 years ago
    Hola! Muchas gracias por tu artículo, ha sido de mucha ayuda, he logrado corregir el tema del formato regional de google cambiando . por ;
    Lo que no consigo hacer es que se actualice la formula cuando ingreso nuevos datos. ¿Sabes cómo hacer esto?
    Gracias
  • To post as a guest, your comment is unpublished.
    coolkev99 · 2 years ago
    Hi everyone. I use this sumColoredCells function but it will NOT auto refresh if you change cell colors. The only way it refreshes is to change a value in the range. A work-around I found was to create a checkbox somewhere to add 1 (or use insignificant fractional (.000001) if you are rounding) to a number in the range, and unchecking will add 0. This will act as a refresh "toggle" switch. Not really ideal, I know... but this is for my personal use and only a minor hassle.
    • To post as a guest, your comment is unpublished.
      sudarshan · 1 years ago
      Hi Kevin,

      Hope you are keeping well. I have been facing the same problem, Can you please share how to create checkbox to add 0000.1 or so. my email id is sudarshan1210@gmail.com. Looking forward to your help.
    • To post as a guest, your comment is unpublished.
      Yara · 1 years ago
      I have the same issue and don't know how to fix it
  • To post as a guest, your comment is unpublished.
    Francisco · 2 years ago
    Thank you so much, truly useful!
  • To post as a guest, your comment is unpublished.
    Roberto · 2 years ago
    There were some errors on the code, like the range not being used at all and that the calculation was only made when the parameters were changed. With this version the calculation will be updated when there is an update on the sheet and the range has to be passed as a string, also some dummy cell has to be used to save a random value, you can put the color of the text just like the background to make it invisible:

    =countColoredCells("B3:B145","B1",$A$1)

    function countColoredCells(countRange, colorRef, unUsed) {
    var backGrounds = SpreadsheetApp.getActiveSheet().getRange(countRange).getBackgrounds();
    var backGround = SpreadsheetApp.getActiveSheet().getRange(colorRef).getBackground();
    var countCells = 0;
    for (var i = 0; i < backGrounds.length; ++i)
    for (var k = 0; k < backGrounds[i].length; ++k)
    if ( backGrounds[i][k] == backGround )
    ++countCells;
    return countCells;
    }

    function onEdit(e)
    {
    SpreadsheetApp.getActiveSheet().getRange('A1').setValue(Math.random());
    }
  • To post as a guest, your comment is unpublished.
    Marco · 2 years ago
    A quick solution but not the best is to add a new parameter and never use it, something like this:

    function sumColoredCells(sumRange,colorRef,test)


    The test parameter is never used, this issue here is that the values only will be refresed if first of all you set the color and then change the value.
  • To post as a guest, your comment is unpublished.
    Adam · 2 years ago
    This script used to work great, but it doesn't work anymore. Is there a change that brought it down?
  • To post as a guest, your comment is unpublished.
    Steve · 2 years ago
    Internet is full of instances of this solution and it doesn't work.
  • To post as a guest, your comment is unpublished.
    Marco · 2 years ago
    Hi there,
    on Google sheets, seems not to be working, I went on debug and for both processes, in row 5 seems to be a type error, the message is: impossible to recall the "pop2 method of null. Does it makes sense? Thanks a lot!
  • To post as a guest, your comment is unpublished.
    desi · 2 years ago
    thank you :*
  • To post as a guest, your comment is unpublished.
    pedro.plj@gmail.com · 2 years ago
    Hello,


    This function works, however, when i try to sum 2 instances of it in the same cell as in (in my case):


    =sumColoredCells(A103:AW103, C171) + sumColoredCells(A138:AW138, C171)


    It gives me an #Error - Range not found (line 6).


    It doesn't work even if i use SUM() or ADD(). Any ideas?


    Thanks in advance.
  • To post as a guest, your comment is unpublished.
    Geoff · 2 years ago
    The SumColoredCells Script works great. Do you know if there is a way to display (in a single cell) the sum of 2 colors? For example, if I wanted the sum of both the Yellow and Green Cells to display in a single cell, is that possible? I would think the formula would be:
    =SUM(sumcoloredcells(A1:E11,A1)),(sumcoloredcells(A1:E11,A5)) ....But that results in an ERROR. Any ideas?
    • To post as a guest, your comment is unpublished.
      skyyang · 2 years ago
      Hello, Geoff,
      May be there is no direct formula to solve your problem, but, you can sum the colored cells separately first, and then, sum the two calculated results as you need.
      • To post as a guest, your comment is unpublished.
        Geoff · 2 years ago
        Thanks for the reply. I have done that, but would love to consolidate the formula into a single cell, as I have to update the ranges every week. Anyway, thanks for checking!
  • To post as a guest, your comment is unpublished.
    jchew · 2 years ago
    Thanks, this worked great!
  • To post as a guest, your comment is unpublished.
    justinbaden9@gmail.com · 3 years ago
    Hello,
    The formula does not work for me.
    If I do this in spreadsheet only errors will occur.
  • To post as a guest, your comment is unpublished.
    danison@bench.co · 3 years ago
    im trying to do something like this
    =countColoredCells (H62:H,B2)countif("MBA13R15")
  • To post as a guest, your comment is unpublished.
    danison@bench.co · 3 years ago
    Hi there,


    Can I need some help with a similar formula to SUM total of number keywords matching and reflecting the number of colors.


    What I what to achieve it determine the number of laptops which is a keyword but recognise the Available based on color of the cells?
  • To post as a guest, your comment is unpublished.
    Raul · 3 years ago
    Replace this lines:
    var countRangeAddress = activeformula.match(/\((.*)\;/).pop().trim();


    var colorRefAddress = activeformula.match(/\;(.*)\)/).pop().trim();

    Notice than , was changed for ;
  • To post as a guest, your comment is unpublished.
    Sam · 3 years ago
    does it auto update when new data is added?
    • To post as a guest, your comment is unpublished.
      Yara · 1 years ago
      No, and I'm trying to find the answer
    • To post as a guest, your comment is unpublished.
      Designedforx · 3 years ago
      Does not seem like it
      • To post as a guest, your comment is unpublished.
        Michael Riddering · 3 years ago
        Did you ever figure out how to get this to auto update?
        • To post as a guest, your comment is unpublished.
          Tomasz B · 2 years ago
          Did anyone find a way to auto update?
          • To post as a guest, your comment is unpublished.
            Sarah · 2 years ago
            I need to figure out how to get it to auto update too!... Anyone find the answer?
            • To post as a guest, your comment is unpublished.
              Eduardo Reyes · 2 years ago
              Did anyone find a way to auto update?
  • To post as a guest, your comment is unpublished.
    Terry · 3 years ago
    I keep getting an error "Action not allowed (Line 0)". What does this mean?
  • To post as a guest, your comment is unpublished.
    Terry · 3 years ago
    I'm getting "Action Not Allowed Line 0" What am I doing wrong?
  • To post as a guest, your comment is unpublished.
    KydKat · 3 years ago
    Is there a way to include negative numbers in the mix and get the correct sum? Mine keeps adding all the numbers in the range, even if the number has a negative sign on it.
  • To post as a guest, your comment is unpublished.
    Laura · 3 years ago
    Hey, thanks for this script. I'm having a problem in the script for google sheets: TypeError: Cannot call method "pop" of null. (line 5, file "SumByColor"). Can you please help?, thanks
    • To post as a guest, your comment is unpublished.
      Patodox · 3 years ago
      The problem maybe is your regional configuration, this script thinks you are separating parameters by ',', but it is not your case probably. In my case, I use ';', so I modified the script, changing the character in the lines

      var countRangeAddress = activeformula.match(/\((.*)\;/).pop().trim();

      var colorRefAddress = activeformula.match(/\;(.*)\)/).pop().trim();
      • To post as a guest, your comment is unpublished.
        Alberto · 1 years ago
        cambio la coma (,) por punto y coma (;) pero aun así no me cuenta el color. me sale como resultado (0 cero).
    • To post as a guest, your comment is unpublished.
      rtapia@colegiohuinganal.cl · 3 years ago
      Hello, I have the same problem, have you fix it?
    • To post as a guest, your comment is unpublished.
      skyyang · 3 years ago
      Hi, Laura,
      The script works well in my google sheets.
      If there is problem in your google sheet, I can share my google sheet with you.
      Please give your email address.
      Thank you!
  • To post as a guest, your comment is unpublished.
    Dave Gorman · 3 years ago
    Your sumColoredCells() function is incorrect as it doesn't use sumRange
    • To post as a guest, your comment is unpublished.
      skyyang · 3 years ago
      Hello, Dave,
      The above script works well in my Google sheet.
      When applying the formula, you should save the script window first.
      Please try it, Thank you!
  • To post as a guest, your comment is unpublished.
    Todd · 3 years ago
    Thanks for the help with "Count cells based on color for google sheets". Limitation seems to be that when cell colors are changed the sheet does not refresh and totals are incorrect. I have to delete the code in the total cell and copy again from neighbour cell. Not ideal, but it works. Thanks again.
    • To post as a guest, your comment is unpublished.
      skyyang · 3 years ago
      Hello, Todd,
      Yes, as you said, you should retype the formula when the cell color changes.
      May be there is no other good ways to solve this problem.
      If any other has good methods, please comment here.
      Thank you!
  • To post as a guest, your comment is unpublished.
    Jose · 3 years ago
    Hey, thanks for this script. I'm having a problem in the script for google sheets: TypeError: Cannot call method "pop" of null. (line 5, file "SumByColor"). Can you please help?, thanks
  • To post as a guest, your comment is unpublished.
    Sheldon · 3 years ago
    Hi! Great script but I run into a problem when trying to edit the values within the coloured cells. The script does not refresh the values if I change the colour of the cell. I can only force it to refresh if i delete the contents of the cell, change the colour and then enter the value again.