first:
remove
Set MyRange = activesheet.Range("A:A")
from the beginning of sub
then rewritted code for cleaning above AAA and below BBB could look like:
For Each Ws In ActiveWorkbook.worksheets
' i am not sure if here you do not need
' Ws.activate
' if code stops here - remove the comment above
set MyRange = Ws.Range("A:A").Find("AAA", LookIn:=xlValues)
if not Myrange is nothing then
Rows("1:" & myrange.row).Delete
end if
set MyRange = Ws.Range("A:A").Find("BBB", LookIn:=xlValues)
if not Myrange is nothing then
Rows(myrange.row & ":" & ws.rows.count).Delete
end if
' here add a column
'like
Columns(1).insert
range("A1")="My header"
Range("A2:A" & myrange.row ).value = ws.name
next ws
PS. If the code stops with error always let us know the error message and in which line it stops. Posting a (sample - no delicate data and not too big one) workbook is always a good idea.
Bookmarks