Hi,

So I have 3 macros in a workbook, each of which has the condition set as If ActiveSheet.CodeName = "XXX" Then ...

The problem is that for one of them the macro still runs in every worksheet. I have tried both activesheet.name and codename with no luck.

If I change between the 2, it will work only once and the the macro will run in every worksheet afterwards.

Below is the macro:

    If ActiveSheet.CodeName = "entry" Then
    Range("B7").Select
    ActiveSheet.Range("$A$6:$I$26").AutoFilter Field:=2, Criteria1:="<>"
    Selection.CurrentRegion.Select
    Selection.Copy
    Range("R7").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Columns("V:w").Select
    Application.CutCopyMode = False
    Selection.Delete Shift:=xlToLeft
    Range("R7").Select
    Selection.CurrentRegion.Select
    Selection.Cut
    Sheets("Receipt details").Select
    Range("Receipt_details[[#Headers],[Entry '#]]").Select
    Selection.End(xlDown).Select
    ActiveCell.Offset(1, 0).Range("Table3[[#Headers],[Entry '#]]").Select
    Sheets("Receipt details entry").Select
    ActiveCell.Offset(22, 3).Range("A1").Select
    Application.CutCopyMode = False
    Else
    MsgBox "wrong sheet"
End If
End Sub
Any help will be appreciated.