Worksheet.sum cache problem

colicab

New Member
Joined
Feb 9, 2015
Messages
2
Hi all. I've written a macro that iterates between several workbooks. Each workbook has a sheet with a data validation list with different "Views" as options. When selecting each view, the workbook automatically hides and unhides columns. All i need to do is, go through every view and get the sum of all cells in the sheet. The macro selects all the cells for both views correctly, but the sum of View1 is equal to sum of View2, where these should be different.

Here's the code I have:

Code:
[COLOR=#333333][FONT=Segoe UI]wbkWorksheets("Sheet1").Activate[/FONT][/COLOR][COLOR=#333333][FONT=Segoe UI]    
'Get data from View1 Sheet1 by selecting all cells, then unselect
    
Cells.Select
View1Sheet1 = WorksheetFunction.sum(Selection)
Range("A1").Select
    
'Get data from View2 Sheet1 by selecting all cells, then unselect

Application.CutCopyMode = False
Range("H8").Value = "View2"
Range("A1").Select
Cells.Select
Range("A1").Select

View2Sheet1 = WorksheetFunction.sum(Selection)[/FONT][/COLOR]

Any help? Thanks!
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

Forum statistics

Threads
1,223,634
Messages
6,173,477
Members
452,516
Latest member
archcalx

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