Maybe I'm trying to use array's wrong but I need some help with the second/last loop where I am trying to change the contents of an array.
Here's the code.
So as you can see I have two tables that have different sets of formula's(nCalc) on the right side. Each table is a different data dump from a data warehouse (xpage 20 aka Aged inventory and 30-NotUsed). My issue occurs right before the Next command. The first nCalc splits into four elements and the second into five. I've tried adding "Erase" but I am getting an error that the array is currently in use.
I appreciate your time and assistance with this question.
Thank you,
Here's the code.
Code:
Sub FeedReset(byValX As Boolean)
Dim nCalc As String, colStatTyp As Integer, ArrayData() As String, Element As Variant
ThisSpot [COLOR=#008000]'Another Sub[/COLOR]
Application.AutoCorrect.AutoFillFormulasInLists = True
For r0 = 1 To 2 Step 1
Select Case r0
Case 1
nPage = xPage10
nCalc = "=[STATUS]&MID([TAG],4,1)|=MID([TAG],4,1)|=IF(COUNTIF(References!$B$4:$D$5,[StatusType])=1,""B"",""N"")|=IF(([YEAR]*1)>YEAR(NOW()),""Future"",IF(LEFT([YEAR],3)=LEFT(YEAR(NOW()),3),""Present"",IF((LEFT([YEAR],3)*1)=(LEFT(YEAR(NOW()),3)*1)-1,""Past"",IF((LEFT([YEAR],3)*1)<(LEFT(YEAR(NOW()),3)*1)-1,""Outdated""))))"
Case 2
nPage = xPage20
nCalc = "=[cvmsstatus]&MID([tag],4,1)|=IF(COUNTIF(References!$B$4:$D$5,[StatusType])=1,""B"",""N"")|=MID([tag],4,1)|=IF(TRIM([noofdays])="""",0,IF([noofdays]>90,""90 + DAYS"",IF(AND([noofdays]>=61, [noofdays]<=90),""61-90 DAYS"",IF(AND([noofdays]>=30,[noofdays]<=60),""30-60 DAYS"",))))|=IF(ISNUMBER([Label]),0,1)"
End Select
resetfilter nPage [COLOR=#008000] 'Another sub that clears the autofilter of the named worksheet, if it is on.
'Created to clear the "current" source [/COLOR][COLOR=#008000]pages, this will be repopulated with the latest data.[/COLOR]
Sheets(nPage).Select
If byValX Then Sheets(nPage).Range(nPage).EntireRow.Delete shift:=xlUp
colStatTyp = Application.WorksheetFunction.Match("StatusType", Sheets(nPage).Range("1:1"), 0)
ArrayData = Split(nCalc, "|") [COLOR=#ff0000]'<-------Subsequent loops issue point[/COLOR]
For Each Element In ArrayData
Sheets(nPage).Cells(2, colStatTyp).Formula = Element
colStatTyp = colStatTyp + 1
Next Element
[COLOR=#ff0000][B] Erase ArrayData '<------------------Issue Point, added when subsequent loops caused an error.[/B][/COLOR]
Next r0
Return2ThisSpot[COLOR=#008000] 'Another Sub[/COLOR]
End Sub
So as you can see I have two tables that have different sets of formula's(nCalc) on the right side. Each table is a different data dump from a data warehouse (xpage 20 aka Aged inventory and 30-NotUsed). My issue occurs right before the Next command. The first nCalc splits into four elements and the second into five. I've tried adding "Erase" but I am getting an error that the array is currently in use.
I appreciate your time and assistance with this question.
Thank you,