Macro to delete selected row from multiple sheets

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
2,679
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
 

Some videos you may like

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.

Osvaldo Palmeiro

Well-known Member
Joined
Feb 24, 2009
Messages
610
Office Version
  1. 365
Platform
  1. Windows
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
 
Solution

Watch MrExcel Video

Forum statistics

Threads
1,123,444
Messages
5,601,704
Members
414,469
Latest member
Murrell78

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
Top