Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I get column letter with API?

Status
Not open for further replies.

brengine

Mechanical
Apr 19, 2001
616
This is probably an easy one, but I've banged my head over it for a couple hours on at least a couple different days...How do I get column letter of the selected cell with API? I can get a number for the column (with cells), or the complete cell address (column letter and row number as one string). But how do I just get the column letter?

Thanks,
Ken
 
Replies continue below

Recommended for you

A bit hacky I'm afraid, but it works:

Private Sub CommandButton1_Click()
strfirst = IIf(Chr$(64 + ActiveCell.Column \ 26) = "@", "", Chr(64 + ActiveCell.Column \ 26))
strletter = strfirst & Chr$(64 + ActiveCell.Column Mod 26)
MsgBox strletter
End Sub


Get the column number, use Mod and Div to get the 2 parts, test for blank first letter and then concatenate.

Good Luck
johnwm
________________________________________________________
To get the best from these forums read faq731-376 before posting
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor