I have a macro that copies a spreadsheet, renames the copy spreadsheet then deduplicates the data range based on a code I've assigned so that only unique items accross the branch remain no matter where they are sold in the branch...it has always worked well using a series of Indirect formulas to create the specific range reference appearing on a helper "Macro Inputs" worksheet that was used in the macro, but using the Indirect function has left me with a worbook that is difficult to maintain because every change requires that I update the static Indirect references. To correct this I created a named range that uses the worksheet name that the copy of the worksheet will become (but it does not exist when the workbook is opened). But, I can't get the macro to work and I cannot figure out why even after many many internet searches...I am receiving a Method "Range" of object'_Global' Failed message with the Set deDupRange line highlighted. Any help you can give me would be appreciated...I am an accountant and not a trained developer (obviously), so I would need a solution to fit that level of knowledge.
Here is the formula I've used to create the dynamic PriceReviewEngineDataRange named range at the workbook level: =PriceReviewEngineByConcept!$A$31:INDEX(PriceReviewEngineByConcept!$DZ:$DZ,COUNTA(PriceReviewEngineByConcept!$A:$A)-COUNTA(PriceReviewEngineByConcept!$A$1:$A$30)+ROW(PriceReviewEngineByConcept!$A$30),1)
Here is the Macro that I'm trying to use the named range in:
Sub conceptLevelReview()
'
' conceptLevelReview Macro
'
Dim sweepTab As String
Dim sweepTabTemp As String
Dim sweepTabConcept As String
Dim deDupRange As Range
Dim indexMatchRange As String
Dim Ans As Integer
Dim rvcCol1 As Integer
Dim rvcCol2 As Integer
Dim qtySoldCol As Integer
Dim priceCol As Integer
Dim discCol As Integer
Dim grossSalesCol As Integer
Dim netSalesCol As Integer
Dim deleteRowRange As String
Ans = MsgBox("WARNING: This macro should only be used before entering new prices or comments as they will be overwritten...do you want to proceed?", vbYesNo)
Select Case Ans
Case vbYes
sweepTab = Sheets("Macro inputs").Range("B126")
sweepTabTemp = Sheets("Macro inputs").Range("B130")
sweepTabConcept = Sheets("Macro inputs").Range("B129")
indexMatchRange = Sheets("Macro inputs").Range("B132")
rvcCol1 = Worksheets("Macro Inputs").Range("B133")
rvcCol2 = Worksheets("Macro Inputs").Range("B134")
qtySoldCol = Worksheets("Macro Inputs").Range("B135")
priceCol = Worksheets("Macro Inputs").Range("B136")
discCol = Worksheets("Macro Inputs").Range("B137")
grossSalesCol = Worksheets("Macro Inputs").Range("B138")
netSalesCol = Worksheets("Macro Inputs").Range("B139")
Sheets("Macro inputs").Calculate
Sheets(sweepTab).Select
ActiveSheet.Calculate
ActiveSheet.Unprotect "core"
With Worksheets(sweepTab)
If .AutoFilterMode Then
If .FilterMode Then
ActiveSheet.ShowAllData
End If
End If
End With
ActiveWorkbook.Unprotect
Sheets(sweepTab).Copy Before:=Sheets(6)
Sheets(sweepTabTemp).Select
Sheets(sweepTabTemp).Name = sweepTabConcept
Set deDupRange = Range("PriceReviewEngineDataRange")
deDupRange.Select
Selection.RemoveDuplicates Columns:=120, Header:= _
xlNo
Bookmarks