Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Old address information updated to current addressi | Excel Worksheet Functions | |||
use current cell address as beginning of macro | Excel Discussion (Misc queries) | |||
Send current file to an e-mail address | Excel Programming | |||
Send current file to an e-mail address | Excel Programming | |||
How do I programmatically know the current cell's address | Excel Programming |