View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
[email protected] theslaveofgod@gmail.com is offline
external usenet poster
 
Posts: 2
Default how to get the column number from the corresponding column nam


Carlo wrote:

Just saw, that you want the other way around :)
it's even easier that way ;)

=IF(LEN(A7)=1;CODE(A7)-64;IF(LEN(A7)=2;(CODE(LEFT(A7;1))-64)*26+CODE(RIGHT(A7;1))-64);"wrong input")

hth

Carlo


"Carlo" wrote:

hi

here's a formula, not the best one, but it works:
=IF(A126;CHAR((A1-IF(MOD(A1;26)=0;26;MOD(A1;26)))/26+64)&CHAR(IF(MOD(A1;26)=0;26;MOD(A1;26))+64);CHA R(A1+64))

A1 is the input field, where the user can enter the column-number!
hth

If anyone has a better solution, please post it, i'm really interested in it.

Cheers
Carlo
" wrote:

hi,
i want to recieve the column number ( ranging from 1 to 256 ) while
the input will be the column name (ranging from A to IV ). please
provide me a macro solution to reach the above mentioned requirement.

Thanks and Regards
Abu.

hey i dont know how to implement the formula you have given.

just answer me like this

function col_number(Col_name)
col_name = "AB"
col_no = ????????
msgbox col_no
end function