×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Determining what column a cell is in?

Determining what column a cell is in?

Determining what column a cell is in?

(OP)
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

RE: Determining what column a cell is in?

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

RE: Determining what column a cell is in?

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

RE: Determining what column a cell is in?

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: www.essexsteam.co.uk

RE: Determining what column a cell is in?

activecell.address will give you row and column

RE: Determining what column a cell is in?

(OP)
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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources