+ Reply to Thread
Results 1 to 5 of 5

Delete Row with Certain Value in Specific Column

  1. #1
    Forum Contributor
    Join Date
    09-13-2012
    Location
    Midwest
    MS-Off Ver
    Excel 365
    Posts
    124

    Delete Row with Certain Value in Specific Column

    I have a database where entries are placed in the next available row. I tried to write a code that would delete the rows where the value in column A of that row is "EXAMPLE". I get the error that rw after Then is an "invalid qualifer". Here is my code:

    Sub deleteExample()
    Dim rw As Long
    With Sheets("Data")
    rw = .Range("A" & .Rows.Count).End(xlUp).Row + 1 ''next available row
    If .Range("A" & rw).Value = "EXAMPLE" Then rw.EntireRow.Delete Shift:=xlUp
    End With

    End Sub

    I suspect this is a simple fix, but I appreciate any help. Thank you!

    Luke

  2. #2
    Forum Contributor
    Join Date
    09-13-2012
    Location
    Midwest
    MS-Off Ver
    Excel 365
    Posts
    124

    Re: Delete Row with Certain Value in Specific Column

    Let me ammend this by saying it is on a protected sheet in a shared workbook. Considering this, I'm not sure it is possible. But any input is appreciated.
    Thank you.

    Luke

  3. #3
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Delete Row with Certain Value in Specific Column

    if you want to do it in an protected sheet, you have to unprotect the sheet first, before running the code, and after that protect the sheet.
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  4. #4
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: Delete Row with Certain Value in Specific Column

    try this macro
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    09-13-2012
    Location
    Midwest
    MS-Off Ver
    Excel 365
    Posts
    124

    Re: Delete Row with Certain Value in Specific Column

    I did some research and found the code I needed:

    Please Login or Register  to view this content.
    For this to work in a protected workbook, you need to make sure the protection option "delete rows" is selected. Then I assigned the macro to a button and it runs great. Thanks all.

    Luke

+ 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