This is more an academic question. I am trying to understand how the 2 Replace functions work in the one line vba code. Now I feel I understand the one part of "REPLACE(#,5,0,"" 2 "")". The syntax looks exactly like the excel function Replace. I am also going to say that after that function is completed the result would be ABCD 2 EFGHI. I just would like confirmation that the place holder or # is the data in cells C1 to C3. This kind of leads me into the next question, how does the place holder get that data?
Ok so the next level Replace gets a little more confusing to me. It looks like the syntax of a VBA Replace.
string1
The string to replace a sequence of characters with another set of characters.
find
The string that will be searched for in string1.
replacement
It will replace find in string1.
If I assume the place holder or # represents the data in cells C1 to C3 than it kind of makes sense.
So in conclusion, I guess the question boils down to, how does the place holder or #, get the data?
Ok so the next level Replace gets a little more confusing to me. It looks like the syntax of a VBA Replace.
string1
The string to replace a sequence of characters with another set of characters.
find
The string that will be searched for in string1.
replacement
It will replace find in string1.
If I assume the place holder or # represents the data in cells C1 to C3 than it kind of makes sense.
So in conclusion, I guess the question boils down to, how does the place holder or #, get the data?
VBA Code:
Sub test04()
Range("C4:C6") = Evaluate(Replace("REPLACE(#,5,0,"" 2 "")", "#", "C1:C3"))
End Sub
20-09-23 Evaluate Len Replace ex 3.xlsm | |||
---|---|---|---|
C | |||
1 | ABCDEFGHI | ||
2 | ABCDEFGHI | ||
3 | ABCDEFGHI | ||
4 | ABCD 2 EFGHI | ||
5 | ABCD 2 EFGHI | ||
6 | ABCD 2 EFGHI | ||
Eval and Replace 2 |