I know that there is a possibility to copy text to a new cell and apply formatting to it. But desirable result is to get formatted text in the same cell.
I have a VBA function, which makes some text replacements:
How it looks like in excel cell: =formStepDescription([@[Step Template]];[@[ST Parameters]];parameters;$A$1)
But it's output is plain text and I need to highlight my substitutions.
The point is that parameters might change and formula should recalculate dynamically.
Function formStepDescription(stepDescriptionTemplate As Range, STParameters, tableWithValues As Range, mode)
Dim stubsList() As String
Dim parametersList() As String
Dim valuesList() As String
If STParameters = "" Then
formStepDescription = stepDescriptionTemplate
Else
stubsList() = Filter(Split(stepDescriptionTemplate), "#param")
parametersList() = Split(STParameters, Chr(10))
valuesList = getValuesByIDs(parametersList, tableWithValues, mode)
formStepDescription = stepDescription(stepDescriptionTemplate, valuesList, stubsList)
End If
End Function
Private Function stepDescription(stepDescriptionTemplate, valuesList() As String, stubsList() As String)
Dim stepDescriptionText As String
stepDescriptionText = stepDescriptionTemplate
For i = 0 To UBound(valuesList)
stepDescriptionText = Replace(stepDescriptionText, stubsList(i), valuesList(i))
Next
stepDescription = stepDescriptionText
End Function