+ Reply to Thread
Results 1 to 6 of 6

Allow ROW deletion but only below a specified range

  1. #1
    Forum Contributor BeachRock's Avatar
    Join Date
    11-01-2011
    Location
    Oregon, United States
    MS-Off Ver
    Excel 2016
    Posts
    403

    Question Allow ROW deletion but only below a specified range

    Hello,

    I am making a budgetary forecast worksheet and I'm hoping someone will know how to do something that I can't.

    How can I either:
    • Force the person to select the cell in column B for any ROW they want to delete

    OR
    • Specify a range that only allows rows below it to be deleted

    Here is what I've been working with.
    Please Login or Register  to view this content.

    The problem is that I have two unlocked cells in row 3 that a person can select and fill from Data Validation Lists to produce monthly and annual expenditures in cells, also located in row 3, which all comes from data in rows from 7 down. If the person happens to have either one of those two cells selected at the time when they run the row deletion macro, it unlocks the sheet and allows that row to go ahead and be deleted, which I don't want to happen, even by accident. I only want them to be able to delete a row if it is below row 6.

    Is this even possible?

    Thanks very much for your help!
    -------------
    Tony

  2. #2
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Allow ROW deletion but only below a specified range

    Tony,

    From your explanation I am concluding that the user can only delete a row via the above macro, and not via right-clicking the row or choosing delete from the menu, right? If that is the case, would it then not be sufficient to check whether the row number of the 'Selection' object is below row 6?
    If you like my contribution click the star icon!

  3. #3
    Forum Contributor BeachRock's Avatar
    Join Date
    11-01-2011
    Location
    Oregon, United States
    MS-Off Ver
    Excel 2016
    Posts
    403

    Re: Allow ROW deletion but only below a specified range

    Hello again, Ollie!

    Correct, I'm not allowing them to delete rows unless they use the macro button. Yes, that would work. I assume it would involve some sort of loop with a message letting them know they must choose a row below row 6 and clicking OK would cause the process to stop.

  4. #4
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Allow ROW deletion but only below a specified range

    Try

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor BeachRock's Avatar
    Join Date
    11-01-2011
    Location
    Oregon, United States
    MS-Off Ver
    Excel 2016
    Posts
    403

    Re: Allow ROW deletion but only below a specified range

    Hi Ollie,

    Your example helped.

    This is what I ended up with.

    Please Login or Register  to view this content.
    Without the else statement and moving things around a bit, it just kept popping up the message box but then didn't delete the row. It works perfectly with the code above.

    Thanks again for your help, Ollie. Very much appreciated!!

  6. #6
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Allow ROW deletion but only below a specified range

    Hi Beachrock,

    In essence that is the same solution. Whether you use end if or else after the exit sub does not matter. Glad it works!

+ 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. Deleting a range of cells based on a deletion of a cell outside that range
    By Carlos90 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-22-2013, 03:07 PM
  2. Selecting all shapes in row range for deletion
    By dystopianprotagonist in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-13-2013, 12:35 PM
  3. Named range deletion
    By ElTerrible35 in forum Excel General
    Replies: 1
    Last Post: 03-04-2009, 07:02 PM
  4. Specific Range Deletion
    By bodhisatvaofboogie in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-24-2006, 09:35 AM
  5. [SOLVED] Excel Event Deletion of a Range
    By [email protected] in forum Excel General
    Replies: 4
    Last Post: 01-23-2006, 08:35 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