Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Determining what column a cell is in? 1

Status
Not open for further replies.

Dalionlv

Civil/Environmental
Jun 28, 2005
2
Ok I have been looking through my vba books and have not found away to test an active cell for the column it's in.

I would like to determine a cells column then do an if statement giving a message box if the cell is in the wrong column.

Thanks for any help
 
Replies continue below

Recommended for you

Here is one way to do it...

Col = Range(cell range).Offset(offset # of Rows, offset # of Colums).Column

You can probably clean it up to something similar to:

Col = Selection.Column
 
Try ActiveCell.Column it returns a long number of the column the active cell is in. If you do MsgBox chr$(ActiveCell.Column + 64) it will give you the column letter.

Regards,

Regg

 
Test for column number using ActiveCell.Column

If you really want the column letter you need to watch out for columns above 26:
Dim x
x = Split(ActiveCell.AddressLocal, "$")
MsgBox x(1)


Good Luck
johnwm
________________________________________________________
To get the best from these forums read faq731-376 before posting

UK steam enthusiasts:
 
Thank you for all of your replies. I used a part of what each of you gave me and it was applicable to my solution. Thanks Again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor