+ Reply to Thread
Results 1 to 8 of 8

Offset named range

Hybrid View

  1. #1
    Registered User
    Join Date
    05-30-2013
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    68

    Offset named range

    I need help to make the below code to be based on named ranges instead of the alphanumeric using offset

    Cell "E36" in page "2013" is named "Start"
    Cell "A1" in sheet "2014" is named "Target"

    Sheets("2013").Range("E37:E2000").Copy
        Sheets("2014").Range("A2").PasteSpecial xlPasteValues 'Nytt Direktvalsnr=Direktval
    //E

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Offset named range

    HI Emma,

    I'm not that familiar with named ranges - so, see if the syntax is appropriate:

    Sheets("2014").Range("Target").Offset(1, 0).Resize(1964, 1).Value = _
        Sheets("2013").Range("Start").Offset(1, 0).Resize(1964, 1).Value
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Offset named range

    Are you looking for the syntax

    Range("MyNamedRange").Copy Destination:= Range("MyOtherNamedRange")
    or (across workbooks) perhaps this syntax

    Dim SourceRange as Range
    Dim DestinationRange as Range
    
    Set SourceRange = Workbooks("Workbook1.xlsm").Names("ANamedRange").RefersToRange
    Set DestinationRange = Workbooks("Workbook2.xlsx").Names("BNamedRange").RefersToRange
    
    SourceRange.Copy Destination:=DestinationRange
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Offset named range

    Hi Mike,

    Is my syntax proper? She wants to use offset with her named ranges

  5. #5
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Offset named range

    Once you have Range("myNamedRange"), its a range object and .Resize or .Offset will work.

    At this point, I think we are both waiting for the OP to explain what "based on named ranges" means to them.

  6. #6
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Offset named range

    @ Mike - It seems that offset and resize always operate on ranges

  7. #7
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Offset named range

    Yeah, my interpretation of the need was "I have a named range, how do I refer to it in VBA?".

  8. #8
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Offset named range

    So, what about my syntax Her named ranges are both just single cells

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Defining a Named Range using Offset
    By Baziwan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-10-2012, 10:21 AM
  2. Named range self-referencing offset
    By kmacd in forum Excel General
    Replies: 7
    Last Post: 03-11-2011, 12:31 PM
  3. Named range offset by row
    By Macdave_19 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-05-2008, 11:45 AM
  4. named range row offset
    By barbetta3141@yahoo.com in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 07-07-2006, 08:45 PM
  5. named range / offset
    By Gixxer_J_97 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-11-2005, 06:06 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1