In the below , the macro will loop till the sheet "XYZ". There are 10 sheets before the sheet "XYZ".
In those 10 sheets i dont want the macro to run on sheet "XBA" and sheet "XBZ".
Please help. I am unable to find exact vba code for this kind of a loop.
Sub Fexp1()
Sheets("AAA").Activate
i = 4
Do Until ActiveSheet.Name = "XYZ"
If ActiveSheet.AutoFilterMode = True Then ActiveSheet.AutoFilterMode = False
Dim sh As Worksheet
Dim rng As Range
Set sh = ActiveSheet
sh.AutoFilterMode = False
sh.Range("$A7:$M7").AutoFilter Field:=7, Criteria1:="x1"
Rowz = sh.AutoFilter.Range.Columns(1).SpecialCells(xlCellTypeVisible).Cells.Count - 1
If Rowz <> 0 Then
Dim rTable As Range
Set rTable = ActiveSheet.AutoFilter.Range
Set rTable = rTable.Resize(rTable.Rows.Count - 1)
Set rTable = rTable.Offset(1)
rTable.Copy
Sheets("EXP1").Select
Range("A1").Select
ActiveCell.End(xlDown).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End If
Sheets(i + 1).Activate
i = i + 1
Loop
Sheets("EXP1").Select
Columns("F:F").Select
Range("F2").Activate
Selection.NumberFormat = "dd/mm/yyyy"
End Sub