Results 1 to 6 of 6
  1. #1
    2 Star Lounger
    Join Date
    Dec 2007
    Posts
    179
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Hi all,

    I always seem to come up with a problem of what is the most elegant way of copying a range from a selection, or a range from another range.

    I do it, but it never seems elegant.

    I do something like
    Rng2.start = Rng1.start
    Rng2.end = Rng1.end

    What about
    Set Rng2 = Rng1(Start:= Rng1.start, End:=Rng1.end)
    ?
    Does this work.
    Definitely not elegant.

    TIA

    - avi

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    You don't mention which application you're using. Am I correct in assuming that it's Microsoft Word?

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    *If* it's Word, you can use

    Set rng2 = ActiveDocument.Range(rng1.Start, rng1.End)

  4. #4
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts
    You can also use
    Code:
    Set Rng2 = Rng1.Duplicate

  5. #5
    2 Star Lounger
    Join Date
    Dec 2007
    Posts
    179
    Thanks
    3
    Thanked 0 Times in 0 Posts
    [quote name='HansV' post='775642' date='18-May-2009 00:17']You don't mention which application you're using. Am I correct in assuming that it's Microsoft Word?[/quote]

    oooops!

    Yes, it's Word.

    Boy, I don't usually make mistakes like that.
    usually very methodical in my titling.

    Thanks,

    avi

  6. #6
    2 Star Lounger
    Join Date
    Dec 2007
    Posts
    179
    Thanks
    3
    Thanked 0 Times in 0 Posts
    [quote name='StuartR' post='775666' date='18-May-2009 08:13']You can also use
    Code:
    Set Rng2 = Rng1.Duplicate
    [/quote]

    Yippeee!

    Thanks Stuart! I have been looking for something like this for years (well one of two).

    Yes - that's elegance. Knew there had to be something better than that ugly start+end assign.

    - avi

Posting Permissions

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