+ Reply to Thread
Results 1 to 7 of 7

Shift contents of cells over one column

  1. #1
    Registered User
    Join Date
    11-21-2012
    Location
    Markham, Ontario
    MS-Off Ver
    Excel 2010
    Posts
    3

    Question Shift contents of cells over one column

    I am writing a macro that will among other things, move a range of cell data over one column. I am attempting to do something like this:

    Please Login or Register  to view this content.
    but the .Paste line gives me an error.

    Run time error '438':
    Object doesn't support this property or method.

    Attempting to use PasteSpecial also gives me a (different) error.

    I have googled some examples of code snippets that seem to do the same thing, so I believe I must be missing something obvious, but a few hours of poking at this hasn't yielded results. Any help would be appreciated.

    Chris
    Last edited by jeffreybrown; 11-21-2012 at 06:23 PM.

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

    Re: Shift contents of cells over one column

    Hello Chris & Welcome to the Forum,

    Why not just shift everything to the right?

    Please Login or Register  to view this content.
    HTH
    Regards, Jeff

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Shift contents of cells over one column

    Hi,

    Range("AJ:BE").Rows(ActiveCell.Row).Cells(1, 1).Insert shift:=xlToRight

    achieves the same result.

    late edit.

    Oops! I see Jeff has beaten me to it
    Last edited by Richard Buttrey; 11-21-2012 at 06:37 PM.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Registered User
    Join Date
    11-21-2012
    Location
    Markham, Ontario
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Shift contents of cells over one column

    Thank you for the welcome, and the quick answers. That almost does what I need, however, the spreadsheet has some conditional formatting and formulas further to the right, and those are being displaced as well. So I guess the difference is that I am trying to shift just the contents (values) over, not the cells themselves. I will keep playing with the Paste and PasteSpecial functions. Thanks.

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

    Re: Shift contents of cells over one column

    Hi Chris,

    Let me know how this works out for you...

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    11-21-2012
    Location
    Markham, Ontario
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Shift contents of cells over one column

    Thanks for the suggestion Jeff. Before I saw your update, I managed to get it working with the copy/paste functions, using the following code:

    Please Login or Register  to view this content.
    Note the commented out cut and clearcontents lines though. Using either cut, or copy and clearcontents caused the later PasteSpecial to give the same error I received before. I could only do it by just doing a copy, and then later clearing the initial cell that got shifted over. Not sure why, but at this point its academic. Thanks again for your assistance.

    Moderator's Note: Please use code tags when posting code.
    Last edited by jeffreybrown; 11-22-2012 at 02:19 PM.

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

    Re: Shift contents of cells over one column

    Glad to hear you got it working and thanks for the feedback.

    ==============================================

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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