Macro variable help

Closed
nimesh - May 14, 2009 at 01:13 PM
 nimesh - May 15, 2009 at 03:09 PM
Hello,

I have declared a variable

Dim x As String
x = Cells(x + 10, 10).Value

I am getting the value of a cell in x. I want to use that value in a sumif function which i have defined below

Cells(y,6).Formula = "=SUMIF(I25:I1000,& x &,F25:F1000)"

y is defined somewhere else so that is not a problem.

I keep getting a error here, how do i pass variable inside a sumif function.

Thanks for all your help

1 response

Looks like you need to add two more quotation marks.


Try this:

Cells(y,6).Formula = "=SUMIF(I25:I1000," & x & ",F25:F1000)"
0
Thanks for your help, it worked but gave me a small problem. In the sumif function it got the exact value from the cell in excel but without the quotes "" in the sumif formulae due to which the sumif function returns a 0. How do i fix that.

Thanks for ur help
0