Macro to delete selected row from multiple sheets

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,194
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi Everyone,

I want a macro that can do this.

I have 5 sheets named
"sales"
"New"
"Old"
"Canceled"
"Data"

I want to be able to select a cell in column A of any of the above sheets and have a macro delete that row in all Sheets

So for example:

I select Sheet"Data" range(A21) if A21 is Empty do nothing,
If A21 is not empty, then message box "You are about to delete Project (and the name in A21) do you want to continue?" if yes
then delete Row 21 entire row from all sheets (
"sales"
"New"
"Old"
"Canceled"
"Data")

message box " Data has been deleted!"

please help if you can

thanks

Tony
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Hi. See if this would help.
VBA Code:
Sub DeleteRowMultipleSheets()
 Dim ws As Worksheet, rw As Long
  If ActiveCell.Value = "" Or ActiveCell.Column > 1 Then Exit Sub
  If MsgBox("You are about to delete Project " & ActiveCell.Value & vbLf _
    & vbLf & "Do you want to continue?", vbYesNo + vbInformation, "A L E R T") = vbYes Then
   rw = ActiveCell.Row
   For Each ws In Sheets(Array("sales", "New", "Old", "Canceled", "Data"))
    ws.Rows(rw).Delete
   Next ws
   MsgBox "Data has been deleted!"
  End If
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,212,927
Messages
6,110,720
Members
448,294
Latest member
jmjmjmjmjmjm

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