I am one step above and Excel nub. Still I am trying sum the values in one column (E) IF the value in a second column (C) is ".pdf" OR ".wbk" (and ideally more that two "OR" conditions:
Sub TestingFunctions()
'SumIf - first arg is the range where condition could exist, second arg is the condition, third arg is the range containing values to sum.
'I have a workbook with a column listing file extensions (Column C) and another listing file size (Column C). I can sum the file size for all files with the single extension .wbk as follows:
MsgBox Application.WorksheetFunction.SumIf(ActiveSheet.Range("C:C"), ".wbk", ActiveSheet.Range("E:E"))
'I can combine the two such statements to sum the size of all file with extensions .pdf or .wbk as follows:
MsgBox Application.WorksheetFunction.Sum(Application.WorksheetFunction.SumIf(ActiveSheet.Range("C:C"), ".pdf", ActiveSheet.Range("E:E")) + Application.WorksheetFunction.SumIf(ActiveSheet.Range("C:C"), ".wbk", ActiveSheet.Range("E:E")))
'Is there a better way? Is there a way to use an OR? E.g., SumIf(C:C, ".pdf" OR ".wbk" OR ".docm", E:E)
'I have tried using SumIfs as follows:
MsgBox Application.WorksheetFunction.SumIfs(ActiveSheet.Range("E:E"), ActiveSheet.Range("C:C"), ".wbk", ActiveSheet.Range("C:C"), ".pdf")
'but this returns 0 (as if it performs as an AND function).
End Sub
Thank you.