INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-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!

*Tek-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.

Jobs

Have Excel Tell Me Active Cell Details

Have Excel Tell Me Active Cell Details

(OP)
So I was working on a little task yesterday (thanks Skip!) and I was trying to figure it out on my own. Always fun.

One thing I was trying to get Excel to do was to tell me what column the "focus" was in, or rather what column number the activecell was. I couldn't. I found this on the support site but I wasn't able to make it work: https://msdn.microsoft.com/en-us/library/office/ff...


So, simply, what would be the VBA syntax to get a message box that says "I'm in Column " & intColumnNumber

Same case, what about the row?

The answer is probably in that link but I'm just not capable of interpreting how to implement it correctly. :(

Thanks!!


Matt

RE: Have Excel Tell Me Active Cell Details

try
Dim r As Range

Set r = ActiveCell 'note use of Set keyword as assigning an Object ref!

MsgBox r.Column & Chr(r.Row + 64)'this will work till column z

RE: Have Excel Tell Me Active Cell Details

better

CODE --> vba

Dim r As Range

Set r = ActiveCell   'note use of Set keyword as assigning an Object ref!

MsgBox Replace(r.Address, "$", "") 

RE: Have Excel Tell Me Active Cell Details

I think PWise got is backwards (in his first post), and Matt wants the numbers for Column / Row:

CODE

Option Explicit

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

MsgBox "I am in Column " & ActiveCell.Column & " Row " & ActiveCell.Row
   
End Sub 

Have fun.

---- Andy

There is a great need for a sarcasm font.

RE: Have Excel Tell Me Active Cell Details

(OP)
Geez I feel dumb, lol. Thanks guys. :)

Thanks!!


Matt

RE: Have Excel Tell Me Active Cell Details

FYI...

CODE

Option Explicit

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
   With Target
      MsgBox "I am in Column " & .Column & " Row " & .Row & " I have " & _
             .Columns.Count & " column(s) selected and " & _
             .Rows.Count & " row(s) selected"
   End With
End Sub 

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: Have Excel Tell Me Active Cell Details

I realize you asked for the information in a message box but on the off-chance you're not aware of these options:
  1. The column and row can be seen on the Name Box on the Formula Bar
  2. Application.StatusBar = "use Skip's text value here..."

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 Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

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

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

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close