Hello,
Why does my formula with vba code
Messed up, this code from vba will show on the master sheet on B9 the formula
but Instead of
=SORT
It shows
=@SORT
' Initialize formula string
formulaString = ""
firstFilter = True
' Include filters for existing tables in all worksheets
For Each ws In ThisWorkbook.Worksheets
For Each tbl In ws.ListObjects
If tbl.Name Like "TBL_*" And tbl.Name <> newTableName Then
If Not firstFilter Then
formulaString = formulaString & ", "
End If
formulaString = formulaString & "FILTER(" & tbl.Name & ", " & tbl.Name & "[MASTER] = TEXTAFTER(CELL(""filename"", A1), ""]""), """")"
firstFilter = False
End If
Next tbl
Next ws
' Add the new table to the formula
If formulaString <> "" Then
formulaString = "=SORT(VSTACK(" & formulaString & ", FILTER(" & newTableName & ", " & newTableName & "[MASTER] = TEXTAFTER(CELL(""filename"", A1), ""]""), """")), 6, 1, FALSE)"
Else
formulaString = "=SORT(FILTER(" & newTableName & ", " & newTableName & "[MASTER] = TEXTAFTER(CELL(""filename"", A1), ""]""), """")), 6, 1, FALSE)"
End If
' Set the formula in cell B9 of the "Master" sheet
On Error Resume Next
masterSheet.Range("B9").ClearContents
masterSheet.Range("B9").Formula = formulaString
Any idea how to solved that?
Thank you