9

In Google Sheets I have a number of columns that I have given titles to in Row 1. Using a formula, I want to return the column number (i.e. 5, 6, 7, ...) for the column that has a specific title. For example: =GetColumnNumber("Account Balance").

This GetColumnNumber() function above doesn't actually exist, but it demonstrates what I'm trying to do.

Is there a way to achieve the same result?

I've found this function reference which I've been trying to sift through.

10

I think this will do what you want. For example if your columns are A to D,

=iferror(match("Account Balance",A1:D1,0),"No match")

returns the column number or an error message.

Thanks for pointing out that function list. It will come in handy.

5

You were right on the money:

=COLUMN(AccountBalance)

Returns the column number for the named range.

You must create a named range using the Data>Named Ranges menu item and the Add a Range option in the resulting sidebar. The name can't contain spaces or other invalid characters and, when used in a function such as the one above, must be unquoted.

  • I just checked that and it doesn't work !! Perhaps you can explain how this solution works? – Jacob Jan Tuinstra Jun 29 '14 at 12:38
  • @JacobJanTuinstra: They've changed the way it functions in recent versions. I've updated my answer to reflect that. – Paused until further notice. Jun 29 '14 at 14:30
  • You're alive !! Wow, thanks Dennis, I've learned something today. – Jacob Jan Tuinstra Jun 29 '14 at 15:40
0

I did it by adding a row that contains the formula =column()
Then find the column number with the vlookupfunction.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.