vba delete more than 1 entry

rjmdc

Well-known Member
Joined
Apr 29, 2020
Messages
708
Office Version
  1. 365
Platform
  1. Windows
current code ask user to be in column a and choose to delete a single entry
how can i amend so that user can select multiple rows (column A only) not necessarily consecutively to perfom the task on ultiple rows
or based on the same idea create a new sub to accomodate for deleting multiple entries

Rich (BB code):
Sub DeletePrintCheck()
    Call WSUnProtect(Worksheets("Check Queue"))
    Dim rng As Range
TryAgain:
Call WSUnProtect(Worksheets("Check Queue"))
    Set rng = Application.InputBox(prompt:="Select entry you want to delete.", Type:=8)
    If rng.Column <> 1 Or rng.Cells.Count <> 1 Then
        MsgBox "You must be in Column A to perform the delete function."
        GoTo TryAgain
    End If
   
    If MsgBox("Are you sure you want to delete: " & rng.Value & " (Row " & rng.Row & ")?", vbYesNo + vbExclamation, "Confirm Delete") = vbNo Then
        Call WSProtect(Worksheets("Check Queue"))
        Exit Sub
    End If
        Call WSUnProtect(Worksheets("Check Queue"))
    Dim tbl As ListObject, LastRow As Range
    Dim col As Long
    Set tbl = Worksheets("Check Queue").ListObjects("tblCheckQueue")
    Dim sr As Long 'Actual Row
    Dim slr As Long 'Start List Row
    sr = rng.Rows(1).Row
    slr = sr - rng.ListObject.Range.Row  'The starting List Row
    rng.ListObject.ListRows(slr).Delete
    Call WSProtect(Worksheets("Check Queue"))
End Sub
 
Last edited by a moderator:

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

Forum statistics

Threads
1,224,820
Messages
6,181,161
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top