Paste a SUM from Sheet 2 into Sheet 1

adamprocter

Board Regular
Joined
Apr 13, 2015
Messages
53
I am trying to build a macro to make some calculations from Sheet 2 and paste the values into Sheet one
The button I have runs the macro from Sheet 1

Code:
Sub MonthlyMacro()

    Sheets("Sheet 1").Range("M6") = "=SUM(Sheet 2!U:U)"
   
End Sub
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Code:
Sub MonthlyMacro()
    Sheets("Sheet1").Range("M6") = "=SUM(Sheet2!U:U)"   
End Sub
 
Upvote 0
Ah sorry my sheets names have spaces I just mocked up dummy names ? I have had no issues with spaces for my other macros?
 
Upvote 0
When sheet names have spaces i htink that you have to put ' before and after the sheet name e.g

Sheets("Sheet1").Range("M6") = "=SUM('Sheet 2'!U:U)"
 
Upvote 0
Thanks! that's got it :)

With this type of SUM I also want to check another column containing dates and compare to be within the same month as TODAY()?
Any advise on that ?

I believe this will check if dates in column A are within the month but how do I combine with my SUM ?

<code>=IFERROR(SMALL(IF(A2:A100>=TODAY(),IF(A2:A100<=TODAY()+30,A2:A100)),1),"")</code>
 
Upvote 0

Forum statistics

Threads
1,214,642
Messages
6,120,700
Members
448,979
Latest member
DET4492

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