VBA Sum function and copying that result to another sheet

Palucci

Banned user
Joined
Sep 15, 2021
Messages
138
Office Version
  1. 365
Platform
  1. Windows
Hello All,

I have a code that is to calculate the sum between two cells and then copy this result to another sheet, I would like the result to stay in f70 and then copy from there . But my code put 0 i dont know why

Rich (BB code):
wbMe.Sheets("blank").Range("F70") = WorksheetFunction.Sum(Range("F68:G68"))
wbMe.Sheets("blank").Range("F70").Copy
wbMe.Sheets("input_6").Cells(3, Columns.Count).End(xlToLeft).Offset(0, 1).PasteSpecial Paste:=xlPasteValues
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
It seems to be working for me.
If you use Sum in Excel to sum that range does it work ?

The only additional thing you could try is to add this line to the bottom (after the paste)
VBA Code:
Application.CutCopyMode = False
 
Upvote 0
It not helped. Is there a chance of the Sum's result directly copied from Range which is counted? not from F70
 
Upvote 0
Did you try in excel to do sum(F68:G68) to see if it works in principle ?
If that works do you know how to step through the code using F8 ?
Is the zero on F70 or in the sheet Input_6 ?
 
Upvote 0
No, macro left that
1632320062876.png
However, if you handle the sum of these cells get the result
 
Upvote 0
Can you step through the lines using F8.
After the first line (and the active line is now the 2nd line) see if there is a value in F70 on sheet "blank"
 
Upvote 0
I see a "dash" on cell and in the formula line on top "0"
 
Upvote 0
It’s after midnight here in Australia are you able to share the workbook via Dropbox, onedrive or other sharing platform and allow anyone with the link to open it and I will have a l look tomorrow?
 
Upvote 0
I am logged off but see if this works

VBA Code:
wbMe.Sheets("blank").Range("F70") = WorksheetFunction.Sum(wbMe.Sheets("blank").Range("F68:G68"))
 
Upvote 0
I have had a chance to test my previous suggestion and it should fix your issue.

Here my updated version of your code, incorporating the above change:
VBA Code:
Sub test()

    Dim wbMe As Workbook
    Set wbMe = ThisWorkbook
    
    With wbMe.Worksheets("blank")
        .Range("F70") = WorksheetFunction.Sum(.Range("F68:G68"))
        .Range("F70").Copy
    End With
    wbMe.Worksheets("input_6").Cells(3, Columns.Count).End(xlToLeft).Offset(0, 1).PasteSpecial Paste:=xlPasteValues

End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,214,786
Messages
6,121,548
Members
449,038
Latest member
Guest1337

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top