I am trying to add in a named range. If I step through the macro, the named range gets added in. If I run the macro, it doesn't. The line is in the code below. I first had it in the "Filter1A" macro, which among other things puts in the data that the named range is going to refer to. It wasn't working there, so I've tried moving it around. I can't find the problem! Help!
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Cell As Range
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
Application.ScreenUpdating = False
'Here's trouble
For Each Cell In Target
If Cell.Address = "$E$1" Then
Application.EnableEvents = False
Range("E2:J2").ClearContents
Range("E3:I3").ClearContents
Application.EnableEvents = True
Filter1A
ThisWorkbook.Names.Add Name:="PertPacs2", RefersTo:="=OFFSET(Temp!$A$1,0,0,COUNTA(Temp!$A:$A),1)"
Exit Sub
Bookmarks