Calculation issues

Newbienew

Active Member
Joined
Mar 17, 2017
Messages
376
Office Version
  1. 2016
Platform
  1. Windows
Good day, all.
My issue is I am lead to believe I am looking for a countif countblank function to achieve my goal. I am looking to count all the ranges with names and no dates in the top right corner, Cell AZ2. The numbers should be 8 as seen in February I am looking to put the function on the sheet2, cell H2



I also have an issue with the Dep accession counter at the top. Similar to my above issue. If there is a number in the ship date range it will be counted. I need it to not to count if the name column has no name. As seen in the month of March. When numbers are deleted, it should be 36 in block A02

I greatly appreciate your time and assistance.

Project 212
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Hi Newbienew,

I see cell AL40 contains =MONTH(TODAY()) but all other month titles are just text. What is the reason? Could the first month ever change from October to some other month?
 
Upvote 0
Newbienew,
Pending your response to my questions above I have hardcoded the row/columns for the ranges to produce the numbers you seek in Sheet2 cells H14 and I14.

NewbieNew DEP STATUS BOARD.xlsx
DEFGHIJKL
1Month Accession depNo DateNo NameRowColumn
2oct10oct0042
3nov8nov00420
4dec10dec00438
5jan8jan00222
6feb0feb802220
7mar0mar0132238
8apr0apr00402
9may0may004020
10jun0jun004038
11jul0jul00582
12aug0aug005820
13sep0sep005838
14813
Sheet2
Cell Formulas
RangeFormula
H2:H13H2=COUNTIFS(OFFSET(Sheet1!$B$1,K2+1,L2-2,15),"<>",OFFSET(Sheet1!$B$1,K2+1,L2+5,15),"")
I2:I13I2=COUNTIFS(OFFSET(Sheet1!$B$1,K2+1,L2-2,15),"",OFFSET(Sheet1!$B$1,K2+1,L2+5,15),">0")
H14:I14H14=SUM(H2:H13)
E2E2=COUNTA(Sheet1!I6:J20)
E3E3=COUNTA(Sheet1!AA6:AB20)
E4E4=COUNTA(Sheet1!AS6:AT20)
E5E5=COUNTA(Sheet1!I24:J38)
E6E6=COUNTA(Sheet1!AA24:AB38)
E7E7=COUNTA(Sheet1!AS42:AT56)
E8E8=COUNTA(Sheet1!$B$42:$E$56)
E9E9=COUNTA(Sheet1!$T$42:$W$56)
E10E10=COUNTA(Sheet1!$AL$42:$AO$56)
E11E11=COUNTA(Sheet1!$B$60:$E$74)
E12E12=COUNTA(Sheet1!$T$60:$W$74)
E13E13=COUNTA(Sheet1!AS60:AT74)
 
Upvote 0
Hi Newbienew,

I see cell AL40 contains =MONTH(TODAY()) but all other month titles are just text. What is the reason? Could the first month ever change from October to some other month?
I forgot that was there. I was attempting to calculate something and found out that what I was trying to calculate wasn't a thing. Sorry about that.

Thank you for your coding I change it a bit and applied it to AO2 & AZ2. It is a bit of a large code but I will keep the coding on sheet 2

I was attempting to use your coding to duplicate similar results. And let's just say it end up with some aspirin, head rubbing, and tears.

The Name column and the ship date should both be counted as one and that number should be displayed in the month title as expressed in march. the number should be 1 and not 13.

The other thing I was attempting to do with your coding was the Highschool and the shipdate should be added up in AB2. the number should be 21 not 36. The code I have works but it is not as efficient as you can see in April where the extra numbers come from.

Project 212x
 
Upvote 0
Newbienew,

Please answer the previous question "Could the first month ever change from October to some other month?" as that will change the formulae.

"The Name column and the ship date should both be counted as one". Yes, that's what the formula does. COUNTIFS uses an "AND" between criteria so only if both conditions are met for that row will the count be incremented.

Here is Sheet2 again with:
  1. I'm afraid I don't understand why you changed the OFFSET command to hard coded as their 12x repetition with hard coded offsets make the formulae impossible to maintain. I have returned the Row and Column numbers to simplify the formulae.
  2. I have replaced your "Month Accession" calculation with one which checks for the presence of both Name and Date. Therefore Sheet1 cell AO2 should simply be =Sheet2!E14
  3. The text boxes are now accurate (i.e. the text box for March of =Sheet2!E7 now correctly shows a 1.
  4. I have added a High School column to count for "*H.S.*" in the data column. Your Sheet1 cell AB2 should therefore be set to =Sheet2!J14

NewbieNew-V2 DEP STATUS BOARD.xlsx
ABCDEFGHIJKL
1H.S. THOMMonth AccessiondepName but no DateDate but no NameHigh SchoolRowColumn
2H.S. WENoct10oct00642
3H.S. EAGnov8nov005420
4H.S. TRIdec10dec005438
5H.S. COLjan8jan005222
6H.S. BOOKfeb0feb8002220
7COLLEGEmar1mar01202238
8apr0apr000402
9may0may0004020
10jun0jun0004038
11jul0jul000582
12aug0aug0005820
13sep0sep0005838
143781221
15
Sheet2
Cell Formulas
RangeFormula
H2:H13H2=COUNTIFS(OFFSET(Sheet1!$B$1,K2+1,L2-2,15),"<>",OFFSET(Sheet1!$B$1,K2+1,L2+5,15),"")
I2:I13I2=COUNTIFS(OFFSET(Sheet1!$B$1,K2+1,L2-2,15),"",OFFSET(Sheet1!$B$1,K2+1,L2+5,15),">0")
J2:J13J2=COUNTIFS(OFFSET(Sheet1!$B$1,K2+1,L2+2,15),"*H.S.*")
E14,H14:J14H14=SUM(H2:H13)
E2:E13E2=COUNTIFS(OFFSET(Sheet1!$B$1,K2+1,L2-2,15),"<>",OFFSET(Sheet1!$B$1,K2+1,L2+5,15),">0")
 
Upvote 0
My apologies I was trying to get everything on one page when I started. I really didn't know what I was trying to figure out and that is how I start out when doing formulas. I believe I might have been confusing in my highschool and date explanation. The formula I had only counted how many times h.s. showed up but it needed to have a date for it to count. I give an example in March. it should be 22 but shows 23.

I dont really understand offset clearly. I been trying to work it out since you introduced it to me. Is it possible to explain how it works if its not too much trouble? Thank you very much for ALL your help and patience with me.

Project 212x
 
Upvote 0
There is no need to apologize, it's your spreadsheet and your data so you can do as you want. It's just that from my side I wouldn't have responded to your original question if I had to interpret a 5 row hard-coded formula so I wondered why you'd gone that direction. I understand you did it as you weren't following my use of OFFSET, so let me try and explain.

Your Sheet2 is looking at 12 months data but the cells you want to check are not contiguous (e.g. not all names for all months are in a single column or single row) so you want to check sets of 15 rows of data for each month.

OFFSET lets you define a matrix of cells against which you can perform a function, such as COUNTIFS.
The format is: OFFSET(reference, rows, cols, [height], [width])
  • The "reference" is the starting point for the matrix. In our case I always use $B$1.
  • The "rows" is how many rows below the "reference" we begin to define the matrix. The months October, November, December are all in row 4, January, February and March in row 22, April, May, June in row 40 and July, August, September in row 58. That is why my Sheet2 column K has those numbers as the row offset.
  • The "cols" is how many columns to the right of the "reference" we begin to define the matrix. Similar as for "rows" I use Sheet2 column L to say that October, January, April and July all start in column B so column 2, November, February, May, August are in column T so column 20, etc.
  • The "[height]" is how many rows are included in the matrix so it is always 15 as all the ranges we want to check (Names, Ship date, Highshcool) are 15 rows of data.
  • The "[width]" is how many columns are included in the matrix but every range we use is a single column so that parameter if omitted and defaults to 1.

Let me correct the Highschool check as an example. For each month you want to count how many times the text "H.S." appears in the Highschool column when there is a number greater than zero in the Ship date.
Sheet2 cell J2 had the formula
Excel Formula:
=COUNTIFS(OFFSET(Sheet1!$B$1,K2+1,L2+2,15),"*H.S.*")
but we need to change it to
Excel Formula:
=COUNTIFS(OFFSET(Sheet1!$B$1,K2+1,L2+2,15),"*H.S.*",OFFSET(Sheet1!$B$1,K2+1,L2+5,15),">0")
so that we also check the Ship date.

First let's interpret the first OFFSET(Sheet1!$B$1,K2+1,L2+2,15)
K2 contains 4 and L2 contains 2 so it becomes
OFFSET(Sheet1!$B$1,5,4,15)
$B$1 plus 5 rows and plus 4 columns becomes $F$6 and with a height of 15 the range is $F$6:$F$20, which is the cells for the October Highschool column.

Now we want to check the Ship date so OFFSET(Sheet1!$B$1,K2+1,L2+5,15) becomes OFFSET(Sheet1!$B$1,5,7,15) so $B$1 plus 5 rows and 7 columns is $I$6 for a height of 15 makes the range $I$6:$I$20

The COUNTIFS becomes
COUNTIFS($F$6:$F$20,"*H.S.*",$I$6:$I$20,">0")
so it returns a count where the wildcard "*H.S.*" is found in $F$6:$F$20 AND $I$6:$I$20 are greater than zero.

This modified formula correctly identifies 22 and not 23 (but should it also check for Name not null?)

Newbienew-V3 DEP STATUS BOARD.xlsx
ABCDEFGHIJKL
1H.S. THOMMonth AccessiondepName but no DateDate but no NameHigh SchoolRowColumn
2H.S. WENoct10oct00642
3H.S. EAGnov8nov005420
4H.S. TRIdec10dec005438
5H.S. COLjan8jan005222
6H.S. BOOKfeb0feb8002220
7COLLEGEmar0mar0112238
8apr0apr100402
9may0may0004020
10jun0jun0004038
11jul0jul000582
12aug0aug0005820
13sep0sep0005838
14369122
Sheet2
Cell Formulas
RangeFormula
H2:H13H2=COUNTIFS(OFFSET(Sheet1!$B$1,K2+1,L2-2,15),"<>",OFFSET(Sheet1!$B$1,K2+1,L2+5,15),"")
I2:I13I2=COUNTIFS(OFFSET(Sheet1!$B$1,K2+1,L2-2,15),"",OFFSET(Sheet1!$B$1,K2+1,L2+5,15),">0")
J2:J13J2=COUNTIFS(OFFSET(Sheet1!$B$1,K2+1,L2+2,15),"*H.S.*",OFFSET(Sheet1!$B$1,K2+1,L2+5,15),">0")
E14,H14:J14H14=SUM(H2:H13)
E2:E13E2=COUNTIFS(OFFSET(Sheet1!$B$1,K2+1,L2-2,15),"<>",OFFSET(Sheet1!$B$1,K2+1,L2+5,15),">0")
 
Upvote 0
not sure I fully grasp the first part of your reply, but regardless I am glad you replied to my initial posting. Thank you for the detailed breakdown of the offset formula. I will have to take some time to master this formula for future use. As for your question about the name not null, that is a great point. It would prevent any misentries and the sheet would be more efficient.
 
Upvote 0
OK, so here's the check for a Name, H.S. and a Ship date. This reduces the count from 22 to 21, so ignoring the first March entry which has no name.

Newbienew-V4 DEP STATUS BOARD.xlsx
ABCDEFGHIJKL
1H.S. THOMMonth AccessiondepName but no DateDate but no NameHigh School, Date & NameRowColumn
2H.S. WENoct10oct00642
3H.S. EAGnov8nov005420
4H.S. TRIdec10dec005438
5H.S. COLjan8jan005222
6H.S. BOOKfeb0feb8002220
7COLLEGEmar0mar0102238
8apr0apr100402
9may0may0004020
10jun0jun0004038
11jul0jul000582
12aug0aug0005820
13sep0sep0005838
14369121
Sheet2
Cell Formulas
RangeFormula
H2:H13H2=COUNTIFS(OFFSET(Sheet1!$B$1,K2+1,L2-2,15),"<>",OFFSET(Sheet1!$B$1,K2+1,L2+5,15),"")
I2:I13I2=COUNTIFS(OFFSET(Sheet1!$B$1,K2+1,L2-2,15),"",OFFSET(Sheet1!$B$1,K2+1,L2+5,15),">0")
J2:J13J2=COUNTIFS(OFFSET(Sheet1!$B$1,K2+1,L2+2,15),"*H.S.*",OFFSET(Sheet1!$B$1,K2+1,L2+5,15),">0",OFFSET(Sheet1!$B$1,K2+1,L2-2,15),"<>")
E14,H14:J14H14=SUM(H2:H13)
E2:E13E2=COUNTIFS(OFFSET(Sheet1!$B$1,K2+1,L2-2,15),"<>",OFFSET(Sheet1!$B$1,K2+1,L2+5,15),">0")
 
Upvote 0
Sir or Ma'am, you are amazing. Seriously. You have my humblest gratitude.
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,732
Members
448,987
Latest member
marion_davis

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