LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 266
Default Get Address of Current Cell

Below is a function that will return the column of a cell. The "CELL"
function will give a column number - I want the column name e.g. "AM". The
function works - sort of. The problem is if I have a cell with "=COL()" I
can't copy that formula to other cells. I think I'm using the wrong Address
(Selection.Address). Any advice is appreciated. Thanks.

Function Col(Optional Column As Integer)

' This Function is used to return the column of a cell - useful for
"INDIRECT" function
' Typical use is =col(CELL("COL",AM1)) - this would return the value "AM"
' Alternatively can be called as =col() which returns the column of the
current cell


Select Case Column

Case Is 0
FC = Chr(Int((Column - 1) / 26) + 64)
SC = Chr(((Column - 1) Mod 26) + 65)
If Column < 27 Then
Col = SC
Else
Col = FC + SC
End If
Case Is = 0
Addr = Selection.Address
First_Dollar = Application.WorksheetFunction.Find("$", Addr, 1)
Second_Dollar = Application.WorksheetFunction.Find("$", Addr,
First_Dollar + 1)

Col = Mid$(Addr, 2, (Second_Dollar - First_Dollar) - 1)
End Select
End Function
 
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
Old address information updated to current addressi Charles Excel Worksheet Functions 1 November 11th 09 03:34 PM
use current cell address as beginning of macro mohavv Excel Discussion (Misc queries) 2 April 18th 08 03:52 PM
Send current file to an e-mail address Gabor G Excel Programming 0 January 24th 04 08:31 AM
Send current file to an e-mail address Gabor G Excel Programming 1 January 23rd 04 12:49 PM
How do I programmatically know the current cell's address Keith[_5_] Excel Programming 3 September 9th 03 08:00 PM


All times are GMT +1. The time now is 08:45 AM.

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"