Convert column # to the letter of the alphabet

J

JimRich

In the following code the uCol value is a number, I need the actual column
letter. Is there an easy way to convert the # to the correct column letter.
I could us an array or a function with a select case but I have at least 180
columns that have to be done. The code is used to determine the location of
a particular Agent's sales data for poping up a chart using that data.

uAdd = ActiveWindow.RangeSelection.Address
uCol = Range(uAdd).Column

Thanks!
 
R

Rick Rothstein

Try this...

uAdd = ActiveWindow.RangeSelection.Address(1, 0)
uCol = Split(uAdd, "$")(0)
 
J

Jacob Skaria

Do you mean

uAdd = ActiveWindow.RangeSelection.Address
uCol = Replace(Cells(1, Range(uAdd).Column).Address(False, False), "1", "")

If this post helps click Yes
 
R

Rick Rothstein

Actually, here is my same method of approach but where you can leave the
first line of code exactly as you originally posted it...

uAdd = ActiveWindow.RangeSelection.Address
uCol = Split(uAdd, "$")(1)
 
R

Rainer Bielefeld

Hi Jim,

try

Debug.Print "# " + Left(Cells(1, uCol).Address(rowabsolute:=True, columnabsolute:=False), InStr(1, Cells(1,
uCol).Address(rowabsolute:=True, columnabsolute:=False), "$", vbTextCompare) - 1)

Maybe a little bit tricky ;-)

Regards,

billy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top