Yes, there is a type mismatch, since "= SUM (F16: G20)" is a string.
The worksheet function should be used to summarize the required range. If there is no desire for something else with a choice, .Select is not required.
Option Explicit Sub autosumtest() Dim total As Integer Dim rng As Range Set rng = Worksheets("Sheet1Test").Range("F16:G20") total = CInt(WorksheetFunction.Sum(rng)) MsgBox (total) End Sub
source share