vba delete more than 1 entry

rjmdc

Well-known Member
Joined
Apr 29, 2020
Messages
693
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

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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