View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default USING THE "&" IN VBA FORMULAS !

The formula property is a string. You must assign a properly formed string.

"=SUM(" & rMyRange.Address(0, 0) ")"

would not be a properly formed string, and would throw a syntax error. You
have three separate parts, a text statement defining the function, a range
string being passed as a variable, and a function end. Three parts need 2
joiners, hence 2 &

"=SUM(" & rMyRange.Address(0, 0) & ")"

--

HTH

RP
(remove nothere from the email address if mailing direct)


"jay dean" wrote in message
...

Hi JE (and Bob Phillips)-
Your example is an example of *exactly* what I was referring to. I
understand the concatenation part.
Question1:
From Range("A1").Formula = "=SUM(" & rMyRange.Address(0, 0) & ")".
Suppose rMyrange was initially set to J1:K100 as you say.
So what exactly is the first ampersand (&) in the formula
concatenating?
What exactly is the second '&' concatenating?
These are what confuse me regarding the use of the ampersand in
formulas. Please break it (the explanation) down for me.

Question2:
If for each cell in Range C2:C200, I would like to input a formula
like cell.formula=DIVIDE cell.offset(0,-1).value by
cell.offset(0,-2).value (ie for each cell in C2:C200 enter formula to
divide the cell one column to the left by the cell two columns to the
left, how do I do that?

Thanks in advance for all your help.
Jay Dean

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!