Trying To Count A Specific # of Columns

msj2487

New Member
Joined
Oct 23, 2018
Messages
6
Hi everyone, I'm new to this site, so I apologize if this has been solved in the past, and I also apologize as I am an amateur with Excel, but I am trying to count a specific # of columns in a spreadsheet.

The concept of the spreadsheet is to display the number of occurrences of a specific criteria based on the value of another cell.

Essentially, I have a list of years going from AI to DL (82 columns of years) and a list of teams from rows 5 through 134 (130 rows of teams) and the values of the cells between these ranges are where the teams finished the season as a ranked team.

What I want my spreadsheet to display is the ability to show a specific criteria, for instance the # of times a team finished ranked #1 , but I want the return value to be determined based off of a searchable cell (for arguments sake, I currently have it set as D2) to where I can input 5 in cell D2 and Excel will count the # of times (countif formula) that the team in Row 12 (just used as an example row) finished ranked #1 during the past 5 years (because D2 is telling it to search 5 columns), and therefore it would only count 5 of the 82 columns for row 12 and also only display the number of times that team finished #1 inside of those 5 columns.

Moreover, if I then changed the searchable cell (D2) to 10, I could see how many times the team finished ranked #1 in the past 10 years, ie. it would 10 of the 82 columns, etc.

So far I've been using the COUNTIF formula, but I can't figure out how to only count a specific # of columns from the table based on the value from the searchable cell (D2).

A work around I have come up with (since again I'm very basic with Excel) is to pair it with an IF formula and sequentially list all possible outcomes someone might search in D2, but that is obviously exhausting and I would assume extremely unnecessary. So the formula that works right now would be:

=IF($D$2=1,(COUNTIF(AI5:AI5,"=1")),IF($D$2=2,(COUNTIF(AI5:AJ5,"=1")),IF($D$2=3,COUNTIF(AI5:AK5,"=1")), and so on until DL5.

I imagine there is an extremely, more condensed formula that could work here and any help would be greatly appreciated!

Thanks so much!
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Try this:

=COUNTIF(INDIRECT(ADDRESS(5,35)&":"&ADDRESS(5,34+D2)),1)

ADDRESS(rownum,colnum) will work out the range you need.
 
Upvote 0
mrshl9898, I apologize for not replying sooner, got caught up with the weekend. However, unfortunately, I could not get that formula to work for me.

Essentially, I have the following spreadsheet:

[TABLE="width: 1509"]
<colgroup><col width="84" style="width: 63pt;"><col width="44" style="width: 33pt;"><col width="52" style="width: 39pt;"><col width="36" style="width: 27pt;"><col width="83" style="width: 62pt;"><col width="41" style="width: 31pt;"><col width="40" style="width: 30pt;"><col width="85" style="width: 64pt;"><col width="80" style="width: 60pt;"><col width="69" style="width: 52pt;"><col width="15" style="width: 11pt;"><col width="41" style="width: 31pt;"><col width="41" span="18" style="width: 31pt;"><col width="60" style="width: 45pt;"><col width="41" style="width: 31pt;"></colgroup><tbody>[TR]
[TD="class: xl65, width: 84, align: center"]View Last:[/TD]
[TD="class: xl69, width: 44, align: center"]83[/TD]
[TD="class: xl65, width: 52, align: center"]Years[/TD]
[TD="class: xl65, width: 36, align: center"][/TD]
[TD="class: xl64, width: 83, align: center"][/TD]
[TD="class: xl64, width: 41, align: center"][/TD]
[TD="class: xl64, width: 40, align: center"][/TD]
[TD="class: xl64, width: 85, align: center"][/TD]
[TD="class: xl64, width: 80, align: center"][/TD]
[TD="class: xl64, width: 69, align: center"][/TD]
[TD="class: xl93, width: 15, bgcolor: black, align: center"] [/TD]
[TD="class: xl64, width: 41, align: center"][/TD]
[TD="class: xl64, width: 41, align: center"][/TD]
[TD="class: xl64, width: 41, align: center"][/TD]
[TD="class: xl64, width: 41, align: center"][/TD]
[TD="class: xl64, width: 41, align: center"][/TD]
[TD="class: xl64, width: 41, align: center"][/TD]
[TD="class: xl64, width: 41, align: center"][/TD]
[TD="class: xl64, width: 41, align: center"][/TD]
[TD="class: xl64, width: 41, align: center"][/TD]
[TD="class: xl64, width: 41, align: center"][/TD]
[TD="class: xl64, width: 41, align: center"][/TD]
[TD="class: xl64, width: 41, align: center"][/TD]
[TD="class: xl64, width: 41, align: center"][/TD]
[TD="class: xl64, width: 41, align: center"][/TD]
[TD="class: xl64, width: 41, align: center"][/TD]
[TD="class: xl64, width: 41, align: center"][/TD]
[TD="class: xl64, width: 41, align: center"][/TD]
[TD="class: xl64, width: 41, align: center"][/TD]
[TD="class: xl64, width: 41, align: center"][/TD]
[TD="class: xl66, width: 60, align: center"]Not Ranked[/TD]
[TD="class: xl68, width: 41, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , align: center"] [/TD]
[/TR]
[TR]
[TD="class: xl64, align: center"][/TD]
[TD="class: xl64, align: center"][/TD]
[TD="class: xl64, align: center"][/TD]
[TD="class: xl64, align: center"][/TD]
[TD="class: xl64, align: center"][/TD]
[TD="class: xl64, align: center"][/TD]
[TD="class: xl64, align: center"][/TD]
[TD="class: xl64, align: center"][/TD]
[TD="class: xl64, align: center"][/TD]
[TD="class: xl64, align: center"][/TD]
[TD="class: xl93, bgcolor: black, align: center"]0[/TD]
[TD="class: xl64, align: center"]1[/TD]
[TD="class: xl64, align: center"]2[/TD]
[TD="class: xl64, align: center"]3[/TD]
[TD="class: xl64, align: center"]4[/TD]
[TD="class: xl64, align: center"]5[/TD]
[TD="class: xl64, align: center"]6[/TD]
[TD="class: xl64, align: center"]7[/TD]
[TD="class: xl64, align: center"]8[/TD]
[TD="class: xl64, align: center"]9[/TD]
[TD="class: xl64, align: center"]10[/TD]
[TD="class: xl64, align: center"]11[/TD]
[TD="class: xl64, align: center"]12[/TD]
[TD="class: xl64, align: center"]13[/TD]
[TD="class: xl64, align: center"]14[/TD]
[TD="class: xl64, align: center"]15[/TD]
[TD="class: xl64, align: center"]16[/TD]
[TD="class: xl64, align: center"]17[/TD]
[TD="class: xl64, align: center"]18[/TD]
[TD="class: xl64, align: center"]19[/TD]
[TD="class: xl64, align: center"]20[/TD]
[TD="class: xl64, align: center"]21[/TD]
[/TR]
[TR]
[TD="class: xl102, width: 84, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D0CECE]#D0CECE[/URL] , align: center"]Total Games Played[/TD]
[TD="class: xl103, width: 44, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D0CECE]#D0CECE[/URL] , align: center"]Wins[/TD]
[TD="class: xl103, width: 52, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D0CECE]#D0CECE[/URL] , align: center"]Losses[/TD]
[TD="class: xl103, width: 36, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D0CECE]#D0CECE[/URL] , align: center"]Ties[/TD]
[TD="class: xl103, width: 83, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D0CECE]#D0CECE[/URL] , align: center"]FCS Opponents[/TD]
[TD="class: xl104, width: 41, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D0CECE]#D0CECE[/URL] , align: center"]Win %[/TD]
[TD="class: xl85, width: 40, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=9BC2E6]#9BC2E6[/URL] , align: center"]Rank[/TD]
[TD="class: xl86, width: 85, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=9BC2E6]#9BC2E6[/URL] , align: center"]Total[/TD]
[TD="class: xl86, width: 80, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=9BC2E6]#9BC2E6[/URL] , align: center"]% of Top 25 Finishes[/TD]
[TD="class: xl87, width: 69, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=9BC2E6]#9BC2E6[/URL] , align: center"]Average Top 25 Ranking[/TD]
[TD="class: xl94, width: 15, bgcolor: black, align: center"] [/TD]
[TD="class: xl66, width: 41, align: center"]2018[/TD]
[TD="class: xl66, width: 41, align: center"]2017[/TD]
[TD="class: xl66, width: 41, align: center"]2016[/TD]
[TD="class: xl66, width: 41, align: center"]2015[/TD]
[TD="class: xl66, width: 41, align: center"]2014[/TD]
[TD="class: xl66, width: 41, align: center"]2013[/TD]
[TD="class: xl66, width: 41, align: center"]2012[/TD]
[TD="class: xl66, width: 41, align: center"]2011[/TD]
[TD="class: xl66, width: 41, align: center"]2010[/TD]
[TD="class: xl66, width: 41, align: center"]2009[/TD]
[TD="class: xl66, width: 41, align: center"]2008[/TD]
[TD="class: xl66, width: 41, align: center"]2007[/TD]
[TD="class: xl66, width: 41, align: center"]2006[/TD]
[TD="class: xl66, width: 41, align: center"]2005[/TD]
[TD="class: xl66, width: 41, align: center"]2004[/TD]
[TD="class: xl66, width: 41, align: center"]2003[/TD]
[TD="class: xl66, width: 41, align: center"]2002[/TD]
[TD="class: xl66, width: 41, align: center"]2001[/TD]
[TD="class: xl66, width: 41, align: center"]2000[/TD]
[TD="class: xl66, width: 60, align: center"]1999[/TD]
[TD="class: xl66, width: 41, align: center"]1998[/TD]
[/TR]
[TR]
[TD="class: xl88, align: center"]103[/TD]
[TD="class: xl64, align: center"]57[/TD]
[TD="class: xl64, align: center"]46[/TD]
[TD="class: xl64, align: center"]0[/TD]
[TD="class: xl64, align: center"]9[/TD]
[TD="class: xl105, align: center"]55%[/TD]
[TD="class: xl88, align: center"]69[/TD]
[TD="class: xl64, align: center"]6[/TD]
[TD="class: xl89, align: center"]7%[/TD]
[TD="class: xl90, align: center"]14[/TD]
[TD="class: xl93, bgcolor: black, align: center"] [/TD]
[TD="class: xl64, align: center"][/TD]
[TD="class: xl64, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , align: center"]0[/TD]
[TD="class: xl64, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , align: center"]0[/TD]
[TD="class: xl64, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , align: center"]0[/TD]
[TD="class: xl64, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , align: center"]0[/TD]
[TD="class: xl64, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , align: center"]0[/TD]
[TD="class: xl64, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , align: center"]0[/TD]
[TD="class: xl64, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , align: center"]0[/TD]
[TD="class: xl64, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , align: center"]0[/TD]
[TD="class: xl64, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , align: center"]0[/TD]
[TD="class: xl64, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , align: center"]0[/TD]
[TD="class: xl64, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , align: center"]0[/TD]
[TD="class: xl64, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , align: center"]0[/TD]
[TD="class: xl64, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , align: center"]0[/TD]
[TD="class: xl64, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , align: center"]0[/TD]
[TD="class: xl64, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , align: center"]0[/TD]
[TD="class: xl64, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , align: center"]0[/TD]
[TD="class: xl64, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , align: center"]0[/TD]
[TD="class: xl64, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , align: center"]0[/TD]
[TD="class: xl64, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=D9D9D9]#D9D9D9[/URL] , align: center"]0[/TD]
[TD="class: xl64, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FF9295]#FF9295[/URL] , align: center"]13[/TD]
[/TR]
</tbody>[/TABLE]


Cell D2 is the square with the "83" in it and below are cells C4 - BC4 for the titles and C5 - BC5 for the values.

The goal for the spreadsheet is to put a formula into J5 that will only count the total number of columns from AI5 - DM5 based on the value in D2.

So if D2 is "5" then J5 will count the number of occurrences where this team finished in the Top 25 of the polls based on the values from AI5 - AM5; which in the above example would be 0.

But if D2 was "21" then J5 would be "1" because they finished #13 in 1998; 21 years ago.

Thanks again for any assistance!
 
Upvote 0

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,631
Latest member
a_potato

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