Address of Top Left Cell

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • EByker
    New Member
    • Apr 2007
    • 18

    Address of Top Left Cell

    Is there a quick way to determine the address of the top left cell of the current selection in an excell spreadsheet?

    Code:
    Selection.Address
    yields the address of the entire selection, which is not what I want. I could of course extract the required information from there (discard everything after the ":"), but that seems a roundabout way.

    Thanks

    EB
  • kadghar
    Recognized Expert Top Contributor
    • Apr 2007
    • 1302

    #2
    Hi,

    selection.row
    selection.colum n

    might be of help, e.g.

    [CODE=vb]Sub MyAdress()
    MsgBox "Column: " & Selection.Colum n & Chr(13) & "Row: " & Selection.Row
    End Sub[/CODE]

    HTH

    (btw, this is my 1000th post here ^.^)

    Comment

    • EByker
      New Member
      • Apr 2007
      • 18

      #3
      Thanks! I used your idea to create the following function:

      Code:
      Function TopLeftAddress()
          TopLeftAddress = Range("A1").Offset(Selection.Row - 1, Selection.Column - 1).Address
      End Function
      
      Sub Test()
          MsgBox TopLeftAddress
      End Sub
      EB

      Comment

      Working...