in excel worksheet i use for example:
=(AVERAGEIFS(B4:B262078,C4:C262078,">"&S2,C4:C262078,"<"&N2,B4:B262078,">"&1130,B4:B262078,"<"&1149))
then in vba i use:
Public SelectedProductMin SelectedProductMax as integers 'IN ANOTHER MODULE
of5minago = WorksheetFunction.AverageIfs(Worksheets("sheet1").Range("B4:B262078"), _
Worksheets("sheet1").Range("C4:C262078"), ">" & Worksheets("sheet1").Range("S2"), _
Worksheets("sheet1").Range("C4:C262078"), "<" & Worksheets("sheet1").Range("N2"), _
Worksheets("sheet1").Range("B4:B262078"), ">" & SelectedProductMin, Worksheets("sheet1").Range("B4:B262078"), "<" & SelectedProductMax)
the above code works in excel vba when i use numbers instead of SelectedProductMin and SelectedProductMax . what i want to do replace 1130 and 1149 with integer variables like above. i declareed the variables public in another module. these two integer variables are based on selected index value from a listview control. i keep getting an error. if use constants it works but not variables. Please help, i could not find any thread anywhere on this
=(AVERAGEIFS(B4:B262078,C4:C262078,">"&S2,C4:C262078,"<"&N2,B4:B262078,">"&1130,B4:B262078,"<"&1149))
then in vba i use:
Public SelectedProductMin SelectedProductMax as integers 'IN ANOTHER MODULE
of5minago = WorksheetFunction.AverageIfs(Worksheets("sheet1").Range("B4:B262078"), _
Worksheets("sheet1").Range("C4:C262078"), ">" & Worksheets("sheet1").Range("S2"), _
Worksheets("sheet1").Range("C4:C262078"), "<" & Worksheets("sheet1").Range("N2"), _
Worksheets("sheet1").Range("B4:B262078"), ">" & SelectedProductMin, Worksheets("sheet1").Range("B4:B262078"), "<" & SelectedProductMax)
the above code works in excel vba when i use numbers instead of SelectedProductMin and SelectedProductMax . what i want to do replace 1130 and 1149 with integer variables like above. i declareed the variables public in another module. these two integer variables are based on selected index value from a listview control. i keep getting an error. if use constants it works but not variables. Please help, i could not find any thread anywhere on this