vba delete more than 1 entry

rjmdc

Well-known Member
Joined
Apr 29, 2020
Messages
672
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 does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

Forum statistics

Threads
1,215,123
Messages
6,123,183
Members
449,090
Latest member
bes000

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