scribbler99
MIS
I'm quite new to this VBA stuff and am obviously having difficulty understanding the different worksheet functions and where to place my code. I have a Summary Worksheet which (each time the workbook opens)I list in column A every worksheet name along with the sum of each corresponding worksheets range E2:E1000 to get a value off each sheet. My purpose of listing each worksheet name dynamically is because the user may Add, ammend, delete or rename these. This all works fine every time I open the work book but what I cannot get my head around is how I get the workbook to recalculate if anything is changed on any of the worksheets without closing the book and reopening it.
I have searched the web and thought I could use the following in the Workbook_SheetChange event
just as a test but this failed. I thought You guys would obviously know why. I have had a similar problem on forcing a change event before and Skip pointed me in the right direction but I obviously am not getting the strategy of where to put my code.
The code I am using is as follows;
I have searched the web and thought I could use the following in the Workbook_SheetChange event
Code:
Worksheets("Summary").Application.Calculate
The code I am using is as follows;
Code:
Private Sub Workbook_Open()
Dim ws
Dim Counter As Integer
Counter = 0
MsgBox "There are " & ThisWorkbook.Worksheets.Count & " Worksheets in this Excel Workbook"
For Each ws In ThisWorkbook.Worksheets
Counter = Counter + 1
'MsgBox ws.Name
If Counter > 1 Then ' This is just to ignore the 1st sheet as that is the summary one
'This next line is just to place a total value spent on each individual sheet
Worksheets(ws.Name).Cells(1, 6).Value = Application.WorksheetFunction.Sum(Worksheets(ws.Name).Range("E2:E1000"))
'This next line is just to list all worksheet names onto Sumamry Sheet
Worksheets("Summary").Cells(Counter, 1).Value = ws.Name
'This next line is to place a total value spent on the summary sheet alongside each sheet name
Worksheets("Summary").Cells(Counter, 2).Value = Application.WorksheetFunction.Sum(Worksheets(ws.Name).Range("E2:E1000"))
End If
Next ws
End Sub