USING THE "&" IN VBA FORMULAS !
& is the concatenation operator - it joins strings. So for
Range("A1").Formula = "=SUM(" & rMyRange.Address(0, 0) & ")"
if rMyRange was set to, say, J1:K100, then rMyRange.Address(0, 0)
returns the string
J1:K100
which & stitches together with the two string "=SUM(" and ")", and the
whole thing would be equivalent to a hard-coded
Range("A1").Formula = "=SUM(J1:K100)"
In article ,
jay dean wrote:
Could somebody please use simple examples to show me how to use the
ampersand "&" correctly in formulas?
I am sorry, I don't understand how the ampersand is used in especially
dynamic formulas. Eg. Range(A1).formula="SUM("&....")
Please *explain* each step of your examples for me to understand.
Thanks.
|