+ Reply to Thread
Results 1 to 3 of 3

Cut overlapping ranges and paste (cut) values only

Hybrid View

  1. #1
    Registered User
    Join Date
    10-11-2012
    Location
    switzerland
    MS-Off Ver
    Excel 2010
    Posts
    38

    Question Cut overlapping ranges and paste (cut) values only

    Hello everyone

    Let's say that I have a range full of entries or blanks (numbers, strings, dates, etc.) in "A1:A10".
    Now, given some conditions, I have to 'move' that range one row down (or more), such that the data ends up in "A2:A11".

    To not mess up my conditional formatting, ONLY the values should be cut/ moved!

    I tried

    Worksheets(1).Range("A2:A11").Value = Worksheets(1).Range("A1:A10").Value
    Problem?
    It does move the values, which is nice, but it leaves the ones above untouched. I could fix this with smart indexing, but my code is already pretty complex, so I'd like to avoid any more indexes if possible.

    I'd wish for something like this

    Worksheets(1).Range("A1:A10").Select
    Selection.Cut Destination:=Worksheets(1).Range("A2:A11")
    to only cut/ paste values, such as:

    Worksheets(1).Range("A1:A10").Cut
    Worksheets(1).Range("A2:A11").PasteSpecial xlPasteValues
    But, the last code does not work with 'Cut', only with 'Copy' ... this is freaking me out

    Help is much appreciated?
    Thank you
    Last edited by nivoe; 11-19-2012 at 04:15 PM.

  2. #2
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Cut overlapping ranges and paste (cut) values only

    Since you are only moving one cell down...

    How about...

    Sub test()
        With Worksheets(1)
            .Range("A1:A10").Copy
            .Range("A2:A11").PasteSpecial xlPasteValues
            .Range("A1").ClearContents
        End With
    End Sub
    ...where you are simple copying, pasting the values, and then clearing A1
    HTH
    Regards, Jeff

  3. #3
    Registered User
    Join Date
    10-11-2012
    Location
    switzerland
    MS-Off Ver
    Excel 2010
    Posts
    38

    Re: Cut overlapping ranges and paste (cut) values only

    Thanks, I guess I have no other choice

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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