1

When i run the code i want the answer of the sum to be displayed in the cell (F 27).

But the sum function does not work nothing is printed into the cells when i run the code. I don't get any errors what so ever.

This is my code

Private Sub TextTotal1_Functions()

Dim SumTotal As Long

SumTotal = WorksheetFunction.Sum(Range("F9:F26"))

Range("F27") = SumTotal

Thanks for your help!

1
  • 2
    Your code works for me without issue. Try your code in a new workbook and see if it works. Commented Oct 19, 2016 at 13:38

3 Answers 3

1

My guess is that you're not specifying the sheet correctly, try the below

Private Sub TextTotal1_Functions()

Dim SumTotal As Long

SumTotal = Application.WorksheetFunction.Sum(Sheets("MySheetNameHere").Range("F9:F26"))

Sheets("MySheetNameHere").Range("F27") = SumTotal
Sign up to request clarification or add additional context in comments.

1 Comment

if you are fully qualifying ranges, you might want to qualify the final range (last line) as well. Sheets("MySheetNameHere").Range("F27") = SumTotal
0

What I usually do when I use WorksheetFunction in VBA, is to write something like this in the immediate window:

?WorksheetFunction.Sum(selection)

and to see whether I am getting what I am expecting from the selection.

Comments

0

Might be the Calculation is set to Manual, so set it back to Automatic:

Application.calcualtion = xlCalculationAutomatic

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.