+ Reply to Thread
Results 1 to 12 of 12

Delete range of selection and shift up

  1. #1
    Registered User
    Join Date
    11-12-2017
    Location
    Stafford, England
    MS-Off Ver
    365
    Posts
    184

    Delete range of selection and shift up

    Hi,

    Working with columns E:K, if any cell in that range is selected then the following formula will delete all cells from E:K on selected row and shift up.
    So if G9 is selected then formula will delete E9:K9 and shift up, works fine for single row but I'm trying to get this to work if multiple rows are selected.
    If G9:G11 is selected the delete E9:K11 and shift up.

    Please Login or Register  to view this content.
    I thought perhaps changing Selection.Row to Selection.Rows but that didn't work

    Thanks

  2. #2
    Valued Forum Contributor
    Join Date
    06-27-2010
    Location
    sYRIA
    MS-Off Ver
    Excel 2013
    Posts
    669

    Re: Delete range of selection and shift up

    What about
    Please Login or Register  to view this content.
    Or
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    11-12-2017
    Location
    Stafford, England
    MS-Off Ver
    365
    Posts
    184

    Re: Delete range of selection and shift up

    Thanks for your reply mohadin

    Your suggestion deletes and shifts up from selection and 5 columns not all of E:K as in OP
    Anything before selected cell does not get deleted

  4. #4
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475

    Re: Delete range of selection and shift up

    Try this.
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    11-12-2017
    Location
    Stafford, England
    MS-Off Ver
    365
    Posts
    184

    Re: Delete range of selection and shift up

    Thanks, I think .Resize is the way forward but possibly change Selection.Offset to Selection.Column or something?

    OP states if any cell is selected, I only used G9 as example
    Working with columns E:K, if any cell in that range is selected then the following formula will delete all cells from E:K on selected row and shift up.

  6. #6
    Valued Forum Contributor
    Join Date
    06-27-2010
    Location
    sYRIA
    MS-Off Ver
    Excel 2013
    Posts
    669

    Re: Delete range of selection and shift up

    Ah
    So may be
    Please Login or Register  to view this content.

  7. #7
    Valued Forum Contributor
    Join Date
    06-27-2010
    Location
    sYRIA
    MS-Off Ver
    Excel 2013
    Posts
    669

    Re: Delete range of selection and shift up

    Other option
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    11-12-2017
    Location
    Stafford, England
    MS-Off Ver
    365
    Posts
    184

    Re: Delete range of selection and shift up

    This is what I used first until I realised .EntireRow would delete data in columns A:D that is required hence needing this to work in range E:K

  9. #9
    Registered User
    Join Date
    11-12-2017
    Location
    Stafford, England
    MS-Off Ver
    365
    Posts
    184

    Re: Delete range of selection and shift up

    Quote Originally Posted by mohadin View Post
    Other option
    Please Login or Register  to view this content.
    Getting error Subscript out of range on:
    z(3) = "K"

  10. #10
    Valued Forum Contributor
    Join Date
    06-27-2010
    Location
    sYRIA
    MS-Off Ver
    Excel 2013
    Posts
    669

    Re: Delete range of selection and shift up

    Last
    Please Login or Register  to view this content.
    Last edited by mohadin; 01-16-2021 at 08:46 AM.

  11. #11
    Registered User
    Join Date
    11-12-2017
    Location
    Stafford, England
    MS-Off Ver
    365
    Posts
    184

    Re: Delete range of selection and shift up

    That was still deleting data in columns A:D however I removed the .EntireRow and it seems to work as I need it to

    Thank you

  12. #12
    Valued Forum Contributor
    Join Date
    06-27-2010
    Location
    sYRIA
    MS-Off Ver
    Excel 2013
    Posts
    669

    Re: Delete range of selection and shift up

    Right my mistake
    Sorry
    any way..

+ 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] Macro to shift data in selected range to top of selection
    By Justair07 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-30-2017, 10:26 AM
  2. Selection.delete Shift:=xlUp Statement Crashing After Certain Number of Rows
    By moosealam in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-05-2014, 06:14 PM
  3. [SOLVED] If criteria met: delete cell and shift to the left but shift only over a certain range
    By olivierpbeland in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-11-2013, 07:44 AM
  4. showing error at Selection.Delete Shift:=xlToLeft
    By anilg0001 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-15-2013, 08:21 AM
  5. [SOLVED] Delete Blanks and Shift Cells Left with Current Selection
    By Bunnyla in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-05-2012, 02:38 AM
  6. Selection.Delete Shift:=xlToLeft (what's the meaning of this?)
    By markx in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-13-2006, 12:55 PM
  7. Excel VBA Selection.Delete Shift:=xlToLeft
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-14-2006, 03:15 PM

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