Hey folks,
I try to sum a column of numbers, based on "string" conditions in anothe column e.g. I want to sum the values in column two which have an A or B in column one.
A 1
B 2
A 4
B 2
C 5
C 7
At the moment I try:
Sub ECS()
Dim EC() As String
EC = Array("DE", "DK", "EE")
Range("I21").Value = Application.WorksheetFunction.SumIfs(Worksheets("Ref").Range("L:L"), Worksheets("Ref").Range("C:C"), "=" & EC)
End Sub
I also tried just EC as a condition and defining EC as a variant but I always get the error "type not compatible" At the end my array will contain over 50 strings.
I found https://www.mrexcel.com/forum/excel-questions/735182-array-values-sumif-criteria-vba.html
but I can't modify it for my request. It also dont know how to handle the {} brackets in VBA and why they are used in this particular formular.
any help would be much appreciated.
kind regards,
dragonx
I try to sum a column of numbers, based on "string" conditions in anothe column e.g. I want to sum the values in column two which have an A or B in column one.
A 1
B 2
A 4
B 2
C 5
C 7
At the moment I try:
Sub ECS()
Dim EC() As String
EC = Array("DE", "DK", "EE")
Range("I21").Value = Application.WorksheetFunction.SumIfs(Worksheets("Ref").Range("L:L"), Worksheets("Ref").Range("C:C"), "=" & EC)
End Sub
I also tried just EC as a condition and defining EC as a variant but I always get the error "type not compatible" At the end my array will contain over 50 strings.
I found https://www.mrexcel.com/forum/excel-questions/735182-array-values-sumif-criteria-vba.html
but I can't modify it for my request. It also dont know how to handle the {} brackets in VBA and why they are used in this particular formular.
any help would be much appreciated.
kind regards,
dragonx