Consulting

Results 1 to 5 of 5

Thread: Solved: Equivalent Range on specific row

  1. #1

    Solved: Equivalent Range on specific row

    Hello,

    I have a named range refering ("Head") to a number of contigious cells on one row ("D4:H4".

    How do I get an equivalent range of the same columns but on a specific row?

    eg. "D6:H6", or "D13:H13"

    I can use Offset and subtract the "Head" row number, but is there a better way.

    Thanks

  2. #2
    VBAX Mentor
    Joined
    Jun 2004
    Posts
    363
    Location
    With Head being a named range of D4:H4, the following will select D7:H7

    [VBA]range("head").offset(3).Select[/VBA]

  3. #3
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    I'd probably use this. I can't see there being something much simpler than you describe.
    [vba]
    rw = rw - Range("Head").Row
    Range("Head").Offset(rw).Select

    [/vba]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  4. #4
    Cheers, that's what I figured.

    Thanks

  5. #5
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,728
    Location
    Also

    [VBA]
    Sub drv()
    Dim r As Range
    Set r = Intersect([head].EntireColumn, Rows(7))
    MsgBox r.Address
    End Sub
    [/VBA]

    Paul

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •