Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Column letter
Need some handy vba code to loop through the columns of a worksheet and
identify which column letter I am currently in, rather than the column number. Any ideas. Thanks, |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Column letter
Hi,
Here are 2 function that do that in a different way. One take the column number a parameter, the other one takes the cell as parameter. '-------------------------------------------------------------- Function ColChar(i As Long) As String ColChar = IIf(i 26, Chr((i - 1) \ 26 + 64), "") & _ Chr((i - 1) Mod 26 + 65) End Function Function colChar2(cell As Range) As String colChar2 = cell.Parent.Cells(1, cell.Cells(1).Column).Address(False, False) colChar2 = Left(colChar2, Len(colChar2) - 1) End Function '------------------------------------------------------------------ -- Regards, Sébastien <http://www.ondemandanalysis.com "Steve" wrote: Need some handy vba code to loop through the columns of a worksheet and identify which column letter I am currently in, rather than the column number. Any ideas. Thanks, |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Column letter
This will convert the column number to the letter(s):
Function Number2Letter(ByVal n As Long) As String 'returns the Excel sheet column letter given a number '---------------------------------------------------- If n 0 And n < 257 Then Number2Letter = Split(Cells(n).Address, "$")(1) Else Number2Letter = Error(9) ' Subscript out of range End If End Function I take you know how to get the column number of the active cell. RBS "Steve" wrote in message ... Need some handy vba code to loop through the columns of a worksheet and identify which column letter I am currently in, rather than the column number. Any ideas. Thanks, |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Get Column Letter | Excel Discussion (Misc queries) | |||
How do I turn excel columns from column number to column letter? | Setting up and Configuration of Excel | |||
How to replace column letter in refferences with a function using the old column letter? | Links and Linking in Excel | |||
How to replace column letter in refferences with a function using the old column letter? | Excel Worksheet Functions | |||
column header changed from letter to number, how return to letter | Excel Discussion (Misc queries) |