Hi guys,
I have a macro which does exactly what I need it to.
The macro is run and then there is another summary tab whichuses formulas with Named Ranges to calculate values.
There are 3 Named Ranges: (on ZTDA Tracker tab)
Units:K:K
Pickers:I:I
Location:H:H
When I run my macro, the named ranges that I have set up arelost and the formulas that use them end up having Reference errors. Is there a wayto set named ranges to run on specific sheets so that when the macro I run, thenamed ranges are kept and the formulas can still calculate?
I can manually change them but it is far more efficient forthe named ranges to remain.
I have a macro which does exactly what I need it to.
The macro is run and then there is another summary tab whichuses formulas with Named Ranges to calculate values.
There are 3 Named Ranges: (on ZTDA Tracker tab)
Units:K:K
Pickers:I:I
Location:H:H
When I run my macro, the named ranges that I have set up arelost and the formulas that use them end up having Reference errors. Is there a wayto set named ranges to run on specific sheets so that when the macro I run, thenamed ranges are kept and the formulas can still calculate?
I can manually change them but it is far more efficient forthe named ranges to remain.
Code:
Sub CompleteMacro()
' ZTDA_Sort_X_51 Macr0
'
'
Sheets("ZTDA Tracker").Select
Cells.Select
Selection.EntireColumn.Hidden = False
Rows("1:4").Select
Selection.Delete Shift:=xlUp
Columns("A:C").Select
Selection.Delete Shift:=xlToLeft
Columns("B:H").Select
Selection.Delete Shift:=xlToLeft
Range("H:H,J:J").Select
Range("J1").Activate
Selection.Delete Shift:=xlToLeft
Rows("1:1").Select
Selection.AutoFilter
ActiveSheet.Range("$A$1:$Y$277").AutoFilter Field:=8, Criteria1:="51"
ActiveSheet.Range("$A$1:$Y$277").AutoFilter Field:=10, Criteria1:="X"
'Delete Hidden
For lp = 256 To 1 Step -1
If Columns(lp).EntireColumn.Hidden = True Then Columns(lp).EntireColumn.Delete Else
Next
For lp = 65536 To 1 Step -1
If Rows(lp).EntireRow.Hidden = True Then Rows(lp).EntireRow.Delete Else
Next
' Compass_Remove_2 Macro
'
'
Columns("C:C").Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("C1").Value = "Compass?"
Range("C2", Range("B" & Rows.Count).End(xlUp).Offset(, 1)).FormulaR1C1 = "=COUNTIF(Mids!R2C3:R804C3,RC2)>0"
With Range("$A$1:$Z$1")
.AutoFilter Field:=3, Criteria1:="TRUE"
.Parent.AutoFilter.Range.Offset(1).EntireRow.Delete
.Parent.AutoFilterMode = False
End With
Sheets("Overs").Select
' Overs_Sort Macro
'
Dim rng As Range
'
Range("1:11,14:14").Select
Range("A14").Activate
Selection.Delete Shift:=xlUp
Columns("A:I").Select
Selection.AutoFilter
ActiveSheet.Range("$A$1:$I$444").AutoFilter Field:=5, Criteria1:=Array( _
"BP10-AMB", "CY10-B/LINE", "GT10-B/LINE", "GT10-NF"), Operator:=xlFilterValues
ActiveSheet.Range("$A$1:$I$444").AutoFilter Field:=6, Criteria1:="OVER"
'Delete Hidden Overs
For lp = 1200 To 1 Step -1
If Rows(lp).EntireRow.Hidden = True Then Rows(lp).EntireRow.Delete Else
Next
Sheets("ZTDA Tracker").Select
' Overs_Match_ZTDA Macro
'
'
Columns("G:G").Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("G1").Value = "Overs Match"
Range("G2", Range("F" & Rows.Count).End(xlUp).Offset(, 1)).FormulaR1C1 = "=COUNTIF(Overs!C1,RC[-1])>0"
With Range("$A$1:$Z$1")
.AutoFilter Field:=7, Criteria1:="FALSE"
.Parent.AutoFilter.Range.Offset(1).EntireRow.Delete
.Parent.AutoFilterMode = False
End With
' Location_Overs_Vlookup Macro
'
'
Columns("H:H").Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("H1").Value = "Location"
Range("H2", Range("G" & Rows.Count).End(xlUp).Offset(, 1)).FormulaR1C1 = "=VLOOKUP(RC[-2],Overs!C[-7]:C[-2],5,FALSE)"
' Picker_Match Macro
'
'
Columns("I:I").Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("I1").Value = "Picker"
Range("I2", Range("H" & Rows.Count).End(xlUp).Offset(, 1)).FormulaR1C1 = "=VLOOKUP(RC[-8],IF(COUNTIF(RC[-1],""*CY10*""),'Input Corby Picker Data'!C1:C6,'Input GT BP Picker Data'!C1:C6),3,FALSE)"
End Sub
Last edited by a moderator: