Take the 2-minute tour ×
Web Applications Stack Exchange is a question and answer site for power users of web applications. It's 100% free, no registration required.

In Google Spreadsheets I have a number of columns that I have given title 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:
http://docs.google.com/support/bin/answer.py?answer=82712&version=static

share|improve this question

migrated from superuser.com Feb 19 '11 at 1:03

This question came from our site for computer enthusiasts and power users.

add comment

2 Answers 2

up vote 4 down vote accepted

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.

share|improve this answer
    
Thanks - this is perfect. –  Turgs Feb 19 '11 at 1:26
add comment

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.

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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