![]() |
writing formula w/ variables
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:" |
writing formula w/ variables
On Jun 30, 1: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:" I used a workaround where I just put the value of var1 in a cell and referanced the cell instead of the variable, but I would definatley appreciate anyone who could tell me what I'm doing wrong... Thanks!!! |
writing formula w/ variables
On Jun 30, 6:38*pm, Matthew Dyer wrote:
On Jun 30, 1: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:" I used a workaround where I just put the value of var1 in a cell and referanced the cell instead of the variable, but I would definatley appreciate anyone who could tell me what I'm doing wrong... Thanks!!! Try your formula on the worksheetput an apostophe in frontcopy to vb editormodidy |
writing formula w/ variables
On 30 June, 16:24, 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:" hi i noticed in your formula that the ampersand symbol(&) is WITHIN the double quotes. this makes it text along with var1. the ampersand symbol should ALWAYS be OUTSIDE of the double quotes ie ..Formula = "=(((COUNT(b:b) +" & var1 & ")*5)-SUM(b:c) )/ " & var1 the above is tested in 03 and works. also I noticed that in your second example, the ampersands are OUTSIDE of the double quotes as is var1. if you have trouble understanding this, look at it this way.... Range("H7").Value = "Inside " & outside & " inside:" the ampersands concatenates all of the text(numbers,other) between the multiple double quotes. anything WITHIN the double quotes is taken literally by excel(VB). anything OUTSIDE the double quotes are declared variables. (you did declare them and assign values, didn't you) regards FSt1 |
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. |
All times are GMT +1. The time now is 10:10 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com