Hi all,
The following line of code writes as SUMIF formula into cell E1:
Range for the SUMIF formula always starts on b1 but the amount of rows needs to be a variable
Sum_range also starts on Y1 but the number of rows needs to be variable as well
Above I used b1:b10 and Y1:Y10 just to force it to work. My question is, how do I get the code to write the formula on a cell with RANGE and sum_range being variables
I tried creating the RANGE using variables, as follows:
The result I got written on the cell e100 was:
=SUMIF(varRangeOfItems1,"=Materials",Y1:Y10)
which gives the error: #NAME? obviously
what I needed written on the cell was: =SUMIF(b1:b10,"=Materials",Y1:Y10), where b1:b10 came from a variable.
Is it possible to achieve what I'm trying to do?
Can somebody shed some light on this?
Thanks in advance
Regards,
Juan
The following line of code writes as SUMIF formula into cell E1:
Code:
Range("e1").Value = "=SUMIF(b1:b10,""Materials"",Y1:Y10)"
Range for the SUMIF formula always starts on b1 but the amount of rows needs to be a variable
Sum_range also starts on Y1 but the number of rows needs to be variable as well
Above I used b1:b10 and Y1:Y10 just to force it to work. My question is, how do I get the code to write the formula on a cell with RANGE and sum_range being variables
I tried creating the RANGE using variables, as follows:
Code:
Set varRangeOfItems1 = ActiveSheet.Range("b1", ActiveSheet.Range("b1").End(xlDown))
Range("e100").Value = "=SUMIF(varRangeOfItems1,""Materials"",Y1:Y10)"
The result I got written on the cell e100 was:
=SUMIF(varRangeOfItems1,"=Materials",Y1:Y10)
which gives the error: #NAME? obviously
what I needed written on the cell was: =SUMIF(b1:b10,"=Materials",Y1:Y10), where b1:b10 came from a variable.
Is it possible to achieve what I'm trying to do?
Can somebody shed some light on this?
Thanks in advance
Regards,
Juan