automatically apply a macro to all worksheets

  • Thread starter Thread starter minrufeng
  • Start date Start date
M

minrufeng

for example, i create a simple macro for inserting a row above a certai
cell. I want the macro applied to all sheets when running the macro
Does anyone know how to do this? thanks a lot
 
try
Sub insertrowinallsheets()
myrow = ActiveCell.Row
For Each ws In Worksheets
ws.Rows(myrow).Insert
Next
End Sub
 
However, if I misoperate a macro to all worksheets and want to undo this
operation, what should I do? Thanks for your great help!
 
Save your workbook before you run this macro.

If you screw it up, then close that workbook without saving and reopen it.
 
try.
Sub insertrowinallsheets()
myrow = ActiveCell.Row
For Each ws In Worksheets
ws.Rows(myrow).DELETE
Next
End Sub
 
Back
Top