How to use names of columns instead of references?

excelos

Well-known Member
Joined
Sep 25, 2011
Messages
592
Office Version
  1. 365
Platform
  1. Windows
Hello

I have a sheet with the first row being the titles of the columns.

I want to use COUNTIFS but I don't want to use the references of the columns as these may change.

I want to use instead the names of the columns.

I use INDEX/MATCH to locate the name of the column I need.

How can I use that information in COUNTIFS so that I specify the column $A:$A to contain the criteria I need?

Thanks!
 
It would help if you gave some exact information, so far you have given us nothing to work with.
I am not willing to keep guessing at what you are trying to do.
Please explain what you are trying to do, where your data is, where your criteria are etc, etc.

I think I did explain what I want to do in my previous post.

The data is not relevant really, it's just a table with the first row being the titles of the columns and the rest rows being the actual data. The problem is that the titles/columns change in order and number.

E.g. one time you may have:
Product;Volume;Location

And the other time you may have:
Location;ID;Product;Volume

I want formulas to COUNTIFS some data.
To do that I want to identify the criteria column by its title, instead its reference, as its reference may change (see example for Product, one time it's column A and the second is column C).

Also, since the number of rows may vary, I want to specify whole columns in the COUNTIFS and not a specific range in the column (e.g. A:A and not A2:A1000) because some times the rows maybe 100 and sometimes they may be 2000.

Any idea?

Thanks

PS:
I know how to use index/match to find the cell of the title I want to apply the COUNTIFS criteria on. But I don't know how to convert that information into its whole column. E.g. the index/match may return C1 for Product, but how do I parse that as $C:$C for the COUNTIFS criterion?
 
Last edited:
Upvote 0

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
something like this?


Book1
ABCDEFGHIJK
1Title1Title2Title3Title4Title5Title6Title7Title8No
21020304050607080Title410
31020304050607080
41020304050607080
51020304050607080
61020304050607080
71020304050607080
81020304050607080
91020304050607080
101020304050607080
111020304050607080
Sheet1
Cell Formulas
RangeFormula
K2=COUNTIFS(INDEX(A:H,,MATCH(J2,$A$1:$H$1,0)),">0")
 
Upvote 0
something like this?


Book1
ABCDEFGHIJK
1Title1Title2Title3Title4Title5Title6Title7Title8No
21020304050607080Title410
31020304050607080
41020304050607080
51020304050607080
61020304050607080
71020304050607080
81020304050607080
91020304050607080
101020304050607080
111020304050607080
Sheet1
Cell Formulas
RangeFormula
K2=COUNTIFS(INDEX(A:H,,MATCH(J2,$A$1:$H$1,0)),">0")

That's interesting, I didn't know you could specify A:H to include the whole columns.

But what if you do not know that your table ends at H?

That's why I was looking to find the end of the table with an INDEX/MATCH on the whole 1st row and then use that reference to do the COUNTIFS
 
Upvote 0
Why can't you use an actual Table?
 
Upvote 0
That's interesting, I didn't know you could specify A:H to include the whole columns.

But what if you do not know that your table ends at H?

That's why I was looking to find the end of the table with an INDEX/MATCH on the whole 1st row and then use that reference to do the COUNTIFS

you can just extend the index range and match to incl all the data
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,173
Members
453,021
Latest member
Justyna P

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