countif combined with logical and

lpvdsteen

Board Regular
Joined
Jan 21, 2003
Messages
161
Office Version
  1. 2016
Platform
  1. Windows
Hi,

My problem is as follows:

I have a row in which a number of cells are non blank
Book3.xls
HIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAMANAOAPAQARASATAUAVAWAXAYAZBABBBCBDBEBFBGBHBIBJBKBLBMBNBOBPBQBRBSBTBUBVBWBXBYBZCACBCCCDCECFCGCHCICJCKCLCMCNCOCPCQCRCSCTCUCVCWCXCY
900:0001:0002:0003:0004:0005:0006:0007:0008:0009:0010:0011:0012:0013:0014:0015:0016:0017:0018:0019:0020:0021:0022:0023:00
10IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
Bond, J


a similar row, on another worksheet in the same workbook, contains a specific value for each colored cell, eg. all blue cells contain the number 1, all yellow cells contain the number 2, all green cells the number 3, and as such another 4 colors.

I need a formula, non VBA, to count cells that are a; not empty in the displayed selection AND contain a number (or are in a specific colored selection) on the other sheet.

In the example, one formula checking for filled blue cells should give me 2, and filled yellow cells should give me 8.

the VBA formula is simple and checks for color;

where ortbereik is the range to count and check, and ortcolor is the color to compare with<font face=Courier New><SPAN style="color:#00007F">Public</SPAN><SPAN style="color:#00007F">Function</SPAN> ortcalc(ortbereik, ortcolor)<SPAN style="color:#00007F">For</SPAN><SPAN style="color:#00007F">Each</SPAN> ortcel<SPAN style="color:#00007F">In</SPAN> ortbereik<SPAN style="color:#00007F">If</SPAN> ortcel.Interior.ColorIndex = ortcolor.Interior.ColorIndex And ortcel<> ""<SPAN style="color:#00007F">Then</SPAN> ortcalc = ortcalc + 0.25<SPAN style="color:#00007F">Next</SPAN><SPAN style="color:#00007F">End</SPAN><SPAN style="color:#00007F">Function</SPAN></FONT>

but I can't copy a VBA formula programmatically into a new workbook without having to perform programmatic changes which I can't ask others to do. Hence my question for a non VBA formula

If anyone can help, be much obliged

Luke
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Assumptions:

1] Range1 is to be checked for non-blank cells and is on Sheet1, H1:X1
2] Range2 is to be checked for a number, which will be given in Sheet1 cell A1, and is on Sheet2!H1:X1
3] in Sheet1, B1, return the count of non-blank cells in Range1 where the same cell in Range2 = Sheet1!A1

=SUMPRODUCT((H1:X1<>"")*(Sheet2!H1:X1=A1))

This should work as long as this statement - "...a similar row, on another worksheet in the same workbook, contains a specific value for each colored cell, eg. all blue cells contain the number 1, all yellow cells contain the number 2, all green cells the number 3, and as such another 4 colors." Your posted exhibit, however, shows all 1's.
 
Upvote 0

Forum statistics

Threads
1,203,663
Messages
6,056,620
Members
444,878
Latest member
SoupLaura

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top