+ Reply to Thread
Results 1 to 3 of 3

Selective Row delete protection

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    09-30-2013
    Location
    Toronto, ON
    MS-Off Ver
    Excel 2007
    Posts
    229

    Selective Row delete protection

    Is it possible to protect a worksheet and allow only certain rows to be deleted? From what I've seen, I don't think so, but I may have missed something.

    See the image for the scenarioCapture.PNG
    Only rows where Mandatory = No can be deleted.
    I control adding rows with a macro (the + button in column A)
    Data can only be entered in columns D, E & F.
    If this helped, please click (*) Add Reputation

  2. #2
    Forum Contributor
    Join Date
    01-04-2013
    Location
    Tampa, Florida
    MS-Off Ver
    Excel 2013
    Posts
    142

    Re: Selective Row delete protection

    The work around is to unprotect and re-protect your sheet within the macro. For some reason I'm unable to view the image you attached so I can't see which column the "Mandatory = No" data is stored. You'll have to adjust the code accordingly.

    Sub DeleteSpecifiedRow()
    
    On Error GoTo ErrorHandler:
    
    Dim lRow As Long
    Dim str As String
    
    str = "password"   'Change this to your actual password within the quotations
    lRow = InputBox("Which row number would you like to delete?")
    
    If Not Range("C" & lRow).Value = "No" Then 'Change C to the column with Mandatory = No data
        MsgBox ("Only rows where Mandatory = No can be deleted")
        Exit Sub
    Else
        ActiveSheet.Unprotect str
        Range("C" & lRow).EntireRow.Delete  'Change C to the column with Mandatory = No data
        ActiveSheet.Protect str
    End If
    
    Exit Sub
    
    ErrorHandler:
    ActiveSheet.Protect str
    MsgBox (Err.Number & vbNewLine & Err.Description)
    
    End Sub
    Last edited by mo4391; 05-26-2016 at 04:05 PM.

  3. #3
    Forum Contributor
    Join Date
    09-30-2013
    Location
    Toronto, ON
    MS-Off Ver
    Excel 2007
    Posts
    229

    Re: Selective Row delete protection

    Budget.jpg
    I've reattached the image.
    This is a budget template.
    I do not want to necessarily delete rows, but want to allow the user to delete rows if they wish.
    They can only delete a row if Mandatory = No.
    If they add a row, using the + button in column A, a macro unprotects the sheet, inserts a row and copies the values in the row where the button was clicked for cells B and C.

    I didn't want to go through asking which row to delete. I was hoping they could do it just via keystrokes.
    I may have them indicate which rows if it has to be done by executing another macro
    Thanks,
    Attached Images Attached Images
    Last edited by hectop; 05-26-2016 at 04:10 PM. Reason: additional feedback

+ 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. Password Protection to delete file or Folder
    By Ratna K. Sthapit in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-11-2014, 10:23 AM
  2. Selective delete using VBA
    By ckattookaran in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-20-2010, 08:03 AM
  3. Excel 2007 : Selective row critera +Delete Characters
    By Rebel_42MDx in forum Excel General
    Replies: 5
    Last Post: 03-11-2010, 02:46 PM
  4. Delete Protection.AllowEditRanges
    By wulffjp in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-20-2009, 06:24 PM
  5. delete a selective word
    By pepeejatt in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-13-2008, 02:44 PM
  6. [SOLVED] SELECTIVE DELETE
    By jhemley@gmail.com in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-15-2006, 05:50 PM
  7. [SOLVED] selective protection
    By Nospam in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-12-2006, 05:30 PM
  8. [SOLVED] Protection-exceptions to delete a row
    By Frederic in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-12-2005, 06:05 AM

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