Home > Software engineering >  VBA: Extracting coordinates of an active cell
VBA: Extracting coordinates of an active cell

Time:07-02

I am new to Excel VBA and what I want to do is the following.

enter image description here

Currently the cell "F3" is active, and I would like to know if there is a function that returns the value "F3".

I imagine that there is a way to extract the 'coordinate' of F3 as (6,3) since F is the 6th letter and 3 is simply 3 (maybe (3,6) if it counts row first and columns later).

If it can return something like (F,3) it would be even better, and best case scenario, F (the column LETTER) by itself.

It is imperative that I am able to extract the column letters because I intend to use this as an input to "replace all letter A to letter B".

If you have an exact answer that would be great, but if you could guide me towards a useful link that would be appreciated, too.

Thank you!!

CodePudding user response:

Try below sub-

Sub GetCellAddress()
Dim x As Variant
    x = Split(ActiveCell.Address, "$")
    MsgBox x(1) & "," & x(2)
End Sub

Result in message box: F,3

  • Related