Range of multiple cells with fixed columns.

  • Hey guys!
    I'm a total noob and I'm struggling with this... Any help would be much appreciated!
    I'm trying to set a range of multiple cells where the rows are fetched from the .Selection property but the columns are fixed values (A_:H_).


    In case I wasn't clear enough regarding what I'm trying to accomplish, here are some examples:


    if my Selection range is (B1:D9), I need to get (A1:H9) range.
    if my Selection range is (C1:P4), I need to get (A1:H4) range.
    if my Selection range is (AA76:BD55), I need to get (A76:H55) range.



    Every tip is much appreciated!


    Cheers!

  • Re: Range of multiple cells with fixed columns.


    Code
    Sub RowFinder()
    Dim FstRow As String 'First Row
    Dim LstRow As String 'Last Row
    FstRow = Split(Selection.Address, "$")(2)
    FstRow = Left(FstRow, Len(FstRow) - 1)
    LstRow = Split(Selection.Address, "$")(4)
    MsgBox "A" & FstRow & ":H" & LstRow, vbInformation, ""
    End Sub

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!