How to delete rows from active rows and show confirm msgBox?

oshi1998

New Member
Joined
Jan 13, 2021
Messages
7
Platform
  1. Windows
Sorry, My english isn't that good. I'm still practicing.

Okay. Hello everyone. I'm a beginner, I need to know source code for this (VBA Macro)

1111.png

Step1 : User select rows need to delete data.
Step2 : User Click 'Delete' Button and show confirm MsgBox and in msgBox show list Id for delete
Example : "Are you sure to delete data ID: 2,3 ?"
Step3 : If User click OK -> Delete rows 3 and 4.

Help me pls. thank you.
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Hi & welcome to MrExcel.
How about
VBA Code:
Sub oshi()
   Dim x As Variant
   With Selection
      If .Rows.Count = 1 Then
         x = .Columns(1).Value
      Else
         x = Join(Application.Transpose(.Columns(1)), ", ")
      End If
      If MsgBox("Are you sure to delete data ID: " & x & "?", vbYesNo) = vbYes Then
         .EntireRow.Delete
      End If
   End With
End Sub
 
Upvote 0
Solution
Hi & welcome to MrExcel.
How about
VBA Code:
Sub oshi()
   Dim x As Variant
   With Selection
      If .Rows.Count = 1 Then
         x = .Columns(1).Value
      Else
         x = Join(Application.Transpose(.Columns(1)), ", ")
      End If
      If MsgBox("Are you sure to delete data ID: " & x & "?", vbYesNo) = vbYes Then
         .EntireRow.Delete
      End If
   End With
End Sub
Thank you very much it works 100% I will learn about this code myself. How it work ?
 
Upvote 0

Forum statistics

Threads
1,213,487
Messages
6,113,943
Members
448,534
Latest member
benefuexx

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