Hello all,
I am starting to use Evaluate in my VBA codes but looks like since I have office 365 & dynamic arrays, it does something for me that makes it work but it doesn't work for older office versions. I have seen some members here use If({1}, to overcome this issue I guess so is this a guaranteed method that should work in all cases ? Shall I just always use it to ensure that my code doesn't fail if used in older excel versions ? What does If({1}, means/signifies ?
I would appreciate your feedback & in case you have a good link to share, please do so
I have put the below example for illustration which makes not difference in my machine since I am using office 365
I am starting to use Evaluate in my VBA codes but looks like since I have office 365 & dynamic arrays, it does something for me that makes it work but it doesn't work for older office versions. I have seen some members here use If({1}, to overcome this issue I guess so is this a guaranteed method that should work in all cases ? Shall I just always use it to ensure that my code doesn't fail if used in older excel versions ? What does If({1}, means/signifies ?
I would appreciate your feedback & in case you have a good link to share, please do so
I have put the below example for illustration which makes not difference in my machine since I am using office 365
VBA Code:
Sub test()
With Range("A2:A11")
.Offset(, 1).Value = Evaluate("len(" & .Address & ")")
.Offset(, 2).Value = Evaluate("if({1},len(" & .Address & "))")
End With
End Sub
Book1 | |||||
---|---|---|---|---|---|
A | B | C | |||
1 | State | without If({1}, | with If({1}, | ||
2 | Colorado | 8 | 8 | ||
3 | New York | 8 | 8 | ||
4 | California | 10 | 10 | ||
5 | Washington | 10 | 10 | ||
6 | Texas | 5 | 5 | ||
7 | Ohio | 4 | 4 | ||
8 | Arizona | 7 | 7 | ||
9 | New Jersey | 10 | 10 | ||
10 | Pennsylvania | 12 | 12 | ||
11 | North Dakota | 12 | 12 | ||
Sheet1 |