Excel VBA Sum from Multiple Sheets

前端 未结 3 429
情话喂你
情话喂你 2021-01-26 04:01

I am trying to create a function or functions that can sum daily hours from time cards for each client to come up with the total hours worked per day. Each client has it\'s own

3条回答
  •  遥遥无期
    2021-01-26 04:43

    The functions return strings and not actual worksheets. The Worksheet does not parse strings well. So add a third function that uses the Evaluate function:

    Function MySum(rng As Range)
    
    MySum = Application.Caller.Parent.Evaluate("SUM(" & FirstSheet & ":" & LastSheet & "!" & rng.Address & ")")
    
    End Function
    

    Then you would simply call it: MySum(A1)

    It uses the other two function you already have created to create a string that can be evaluated as a formula.

提交回复
热议问题