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

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
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,214,627
Messages
6,120,610
Members
448,973
Latest member
ChristineC

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