add more text etc to end of array elememt
I want to look in all the strings of an array for a substring that has the value of my variable 'Get' in it. Then, I want to add "SB =" and the value of variable SBValue (As Long) to the end of the string in each array element that contains the value of "Get". Eventually all elements of FineArr get "joined" and used in a text file.
All variables and arrays are declared, I think I just don't have the right syntax, or the right idea?
For I = LBound(FineArr) To UBound(FineArr)
If Instr(FineArr(I), Get) Then Tmp2 = FineArr(I), "SB =", SBValue
FineArr(I) = Tmp2
Next I
I'm sure there is a better way to add the necessary to each array element without using a temporary string?
Re: add more text etc to end of array elememt
It's a minor syntax issue, instead of using a comma you should use an ampersand (&), eg:
Code:
If Instr(FineArr(I), Get) Then Tmp2 = FineArr(I) & "SB =" & SBValue
(it is possible to use + but that causes problems in some circumstances)
You also don't need to use a temporary string, you can assign directly back to the same array element:
Code:
If Instr(FineArr(I), Get) Then FineArr(I) = FineArr(I) & "SB =" & SBValue
Re: add more text etc to end of array elememt
Thanks Si, that is now done.