Aug 09 2023 08:40 AM
Not sure if possible, but how would you write a formula in one cell to count a row of cells that aren't filled in as black, then count the cells that have an "X" within that range and then divide the number of cells that have an "X" by the number of cells that aren't filled in as black? I did a workaround and did each function separately in different cells, but wanted to see if it can be done in one function.
Aug 09 2023 09:11 AM
Aug 09 2023 09:18 AM - edited Aug 09 2023 09:21 AM
Para personalizar a função NOT no VBA:
Function NOT(cell As Range, color As String) As Boolean If cell.Interior.Color = RGB(0, 0, 0) And color = "black" Then NOT = False Else NOT = True End If End Function
Salve o módulo e feche o editor do VBA. (fonte de informação: Bing)
Observe que essa é apenas uma maneira de personalizar a função NOT no VBA do Excel. Você pode ajustar o código acima para atender às suas necessidades específicas.
Aug 09 2023 09:24 AM
Not sure if possible, but how would you write a formula in one cell to count a row of cells that aren't filled in as black, then count the cells that have an "X" within that range and then divide the number of cells that have an "X" by the number of cells that aren't filled in as black? I did a workaround and did each function separately in different cells, but wanted to see if it can be done in one function.
If your workaround works, it would be possible to nest one of those formulas within the other, or, maybe even better, to nest both of them within a third along the lines of the following:
=(formula that counts cells with "X")/(formula that counts cells not filled in)
And if you have a Microsoft 365 subscription you could use the LET function, as in
=LET(black,(formula that counts black cells),xcells,(formula that counts "X"s),xcells/black)
Aug 10 2023 08:29 AM
Thanks, I tried both ways and got the nesting to work because I assigned the cells filled in with black with a "1" as I have other cells in the same row that are yellow which I want to count along with the x's
=COUNTIF(C71:AF71,"X")/COUNTIF(C71:AF71,"<>"&$BE$2)
for the let function, it worked but, it wasn't calculating correctly with the BE2 cell reference, so I had to put the "1" value
=LET(xcell,COUNTIF(C71:AF71,"x"),black,COUNTIF(C71:AF71,"<>1"),xcell/black)
If I just have a fill color in a cell and want to count by that color without having to put in a value is it possible to do that?
Aug 10 2023 09:01 AM
If I just have a fill color in a cell and want to count by that color without having to put in a value is it possible to do that?
If it is possible, it's not something I know how to do. (I've looked briefly and not found a method.)
But, on top of that, I'm not sure it would be a good practice even if it were possible. It would seem to me (not knowing your full situation, of course, so willing to be corrected on this)...it would seem to me that you'd be relying on a manual process to do something that could be automated (via Conditional Formatting), and would be more reliable. That is assuming that there is some consistent set of conditions that lie behind your wanting to fill cells with this or that color, and that those conditions are to be found in one or more pieces of data elsewhere in the spreadsheet.
So why don't you start with considering the reasoning behind the color fills that you might want to consider: are they reasons/conditions that could themselves be programmed/automated?