writing formula w/ variables
On Jun 30, 3:24*pm, Matthew Dyer wrote:
This should be a simple solution but I can't figure it out... Here is
the line of code I'm having issues with -
* * .Formula = "=(((COUNT(b:b)+" & var1 & ")*5)-SUM(b:c))/" & var1 &"
Why isn't this working for me? I used the same basic "& _ &" roadmap
in the following code with no problem
Range("H7").Value = "In " & var1 & " Days:"
Well, stubbed in this code
Dim rnga As Range, var1 As Double
Set rnga = Range("A1")
var1 = 8
With rnga
.Formula = "=(((COUNT(b:b)+" & var1 & ")*5)-SUM(b:c))/" & var1 & "
"
End With
and it worked fine. I did notice that Excel added another double
quote at the end. When I look at the formula it pasted into A1, I
get:
=(((COUNT(B:B)+8)*5)-SUM(B:C))/8
Perhaps you could give us a little more than one line of code.
Chris M.
|