This one worked perfectly! I just had to add a dictionary in order to save the variables. What I need next is a way to combine the dynamic variables into a new variable where the length depends on the number of dynamic variables.
Let's say that I have now have have i numbers of dynamic variables, and I want to create a string that consists of these variables:
stringEnd = dynVariable(1) & dynVariable(2) & ... & dynVariable(i)
If I have two dynamic variables like below I want to end up with:
stringEnd = dynVariable(1) & dynVariable(2)
However, if I have four dynamic variables, I want to end up with:
stringEnd = dynVariable(1) & dynVariable(2) & dynVariable(3) & dynVariable(4)
etc.. Anyone who knows how I can work this out?
Private Sub get_substringss()
Dim x, y, z, i, a, b, c
Dim dynVariable As Object, stringOriginal As String, stringEnd as string
Set dynVariable = CreateObject("Scripting.Dictionary")
stringOriginal = "I want to go to %Paris% and have a %lunch%."
x = Split(stringOriginal, "%")
y = UBound(x)
For a = 1 To y Step 2
b = b + 1
z = Mid(Columns(b).Address, 2, 1)
dynVariable(b) = x(a)
Next a
stringEnd = dynVariable(1) & dynVariable(2) & ... & dynVariable(i)
End sub
Bookmarks