Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default getting the column name

I need to put the column name in a variable when I stand on a cetain cell.
If I use activecell.column
I get the column number, but I need the name.
When I'm in cell C5 I want to put C in a variable (and not the columnindex
3), and when I'm in cell HD3 then I want to get HD instead of 212.

Can anyone help me with this?
I know I can get the whole adress from the activecell and then trim it but I
guess that there's an easier way.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default getting the column name

"sbdproj" skrev i melding
...
When I'm in cell C5 I want to put C in a variable (and not the columnindex
3), and when I'm in cell HD3 then I want to get HD instead of 212.

Can anyone help me with this?
I know I can get the whole adress from the activecell and then trim it but

I
guess that there's an easier way.


I don't think so
=MID(ADDRESS(1,COLUMN()),2,1+(COLUMN()26))
but hopefully I'm wrong.
--
HTH. Best wishes Harald
Followup to newsgroup only please


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 111
Default getting the column name

Hej Harald

A bit shorter :-)

=SUBSTITUTE(ADDRESS(1,COLUMN(),4),1,"")

--
Best Regards
Leo

"Harald Staff" skrev i en meddelelse
...
"sbdproj" skrev i melding
...
When I'm in cell C5 I want to put C in a variable (and not the

columnindex
3), and when I'm in cell HD3 then I want to get HD instead of 212.

Can anyone help me with this?
I know I can get the whole adress from the activecell and then trim it

but
I
guess that there's an easier way.


I don't think so
=MID(ADDRESS(1,COLUMN()),2,1+(COLUMN()26))
but hopefully I'm wrong.
--
HTH. Best wishes Harald
Followup to newsgroup only please





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default getting the column name

Neat :-)

Best wishes Harald
Followup to newsgroup only please

"Leo Heuser" skrev i melding
...
=SUBSTITUTE(ADDRESS(1,COLUMN(),4),1,"")



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default getting the column name

I picked this up from another thread - Mr Ogilvy I think -

Public Function CLetter(rng As Range) As String
CLetter = Left(rng.Address(False, False), _
1 - CInt(rng.Column 26))
End Function


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default getting the column name

Pickedthis up from an earlier thread - Mr Ogilvy I think.

Works like a charm in 97

Public Function CLetter(rng As Range) As String
CLetter = Left(rng.Address(False, False), _
1 - CInt(rng.Column 26))
End Function
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 111
Default getting the column name

One way:

ColumnName = Split(ActiveCell.Address, "$")(1)

The SPLIT function was first introduced in Excel 2000.

--
Best Regards
Leo Heuser
Excel MVP

Followup to newsgroup only please.

"sbdproj" skrev i en meddelelse
...
I need to put the column name in a variable when I stand on a cetain cell.
If I use activecell.column
I get the column number, but I need the name.
When I'm in cell C5 I want to put C in a variable (and not the columnindex
3), and when I'm in cell HD3 then I want to get HD instead of 212.

Can anyone help me with this?
I know I can get the whole adress from the activecell and then trim it but

I
guess that there's an easier way.




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
divide column(x) by column(y) to give column(x/y) in excel? James New Users to Excel 2 April 24th 23 11:46 AM
Referencing date column A & time column B to get info from column TVGuy29 Excel Discussion (Misc queries) 1 January 24th 08 09:50 PM
Return text in Column A if Column B and Column K match jeannie v Excel Worksheet Functions 4 December 13th 07 07:36 PM
Based on a condition in one column, search for a year in another column, and display data from another column in the same row look [email protected] Excel Discussion (Misc queries) 1 December 27th 06 05:47 PM
formula : =(column A)+(column B)-(column C). Why won't it work? Kristin Drover Excel Discussion (Misc queries) 3 October 18th 06 08:48 PM


All times are GMT +1. The time now is 10:00 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"