+ Reply to Thread
Results 1 to 3 of 3

Auto Calculate Macros when worksheet data updated or changes in multiple cells

  1. #1
    Registered User
    Join Date
    09-01-2013
    Location
    Krugersdorp, South Africa
    MS-Off Ver
    Excel 2007
    Posts
    1

    Auto Calculate Macros when worksheet data updated or changes in multiple cells

    Hi,

    I would appreciate assistance with my workbook. I am an extreme novice with Excel Macros and VBA. I developed a tool for use in my work as a compliance officer.

    My brother-in-law who is a programmer assisted with developing the macros for the workbook, but wasnt too keen on assisting me with completing it. He last used Macros and VBA many moons ago. Anyway, I have been trying to read around for solutions, without much luck.

    The ultimate aim is to have the macros contained in the QA Scoring worksheet, run when the data from the consultant worksheets 1 - 20 is updated. The scores from the consultant worksheets update the cells in column F18 through to F197 contained in the QA Scoring worksheet are meant to automatically update the macros contained in cells Q2 to Q7 and K7 (Agents in Selection) of the QA Scoring worksheet. Alternatively, all macros would be updated after all data has been inputted and a calculate button is clicked.

    The aim is for clients to use the tool for QA scoring and not have to run each and every macro to update the QA Scoring sheet, thus their input will be limited to inputting the raw data in consultant worksheets 1 to 20 and clicking on the calculate button (which I have no idea how to develop) in cell K10.

    Below is the code that was used.

    Sub OpeningDisclosures()
    '
    ' Opening Disclosure
    '

    Dim Total As Double
    Dim i As Integer

    For i = 18 To 189 Step 9
    Total = Total + Sheet2.Cells(i, 6)
    Next i

    Sheet2.Cells(2, 17) = Total
    End Sub
    Sub InformationGiven()
    '
    ' InformationGiven Macro
    '
    Dim Total As Double
    Dim i As Integer

    For i = 19 To 190 Step 9
    Total = Total + Sheet2.Cells(i, 6)
    Next i

    Sheet2.Cells(3, 17) = Total
    End Sub

    Sub BenefitsandCovers()
    '
    ' BenefitsandCovers Macro
    '
    Dim Total As Double
    Dim i As Integer

    For i = 20 To 191 Step 9
    Total = Total + Sheet2.Cells(i, 6)
    Next i

    Sheet2.Cells(4, 17) = Total
    End Sub
    Sub ConditionsandExclusions()
    '
    ' ConditionsandExclusions Macro
    '
    Dim Total As Double
    Dim i As Integer

    For i = 21 To 192 Step 9
    Total = Total + Sheet2.Cells(i, 6)
    Next i

    Sheet2.Cells(5, 17) = Total
    End Sub
    Sub PolicyDocumentandCoolingOff()
    '
    ' PolicyDocumentandCoolingOff Macro
    '
    Dim Total As Double
    Dim i As Integer

    For i = 22 To 193 Step 9
    Total = Total + Sheet2.Cells(i, 6)
    Next i

    Sheet2.Cells(6, 17) = Total
    End Sub
    Sub FinancialNeedsAnalysis()
    '
    ' FinancialNeedsAnalysis Macro
    '
    Dim Total As Double
    Dim i As Integer

    For i = 23 To 194 Step 9
    Total = Total + Sheet2.Cells(i, 6)
    Next i

    Sheet2.Cells(7, 17) = Total
    End Sub
    Sub Termination()
    '
    ' Termination Macro
    '
    Dim Total As Double
    Dim i As Integer

    For i = 24 To 195 Step 9
    Total = Total + Sheet2.Cells(i, 6)
    Next i

    Sheet2.Cells(8, 17) = Total
    End Sub
    Sub Closings()
    '
    ' Closings Macro
    '
    Dim Total As Double
    Dim i As Integer

    For i = 25 To 196 Step 9
    Total = Total + Sheet2.Cells(i, 6)
    Next i

    Sheet2.Cells(9, 17) = Total
    End Sub
    Sub DeviationfromScript()
    '
    ' DeviationfromScript Macro
    '
    Dim Total As Double
    Dim i As Integer

    For i = 26 To 197 Step 9
    Total = Total + Sheet2.Cells(i, 6)
    Next i

    Sheet2.Cells(10, 17) = Total
    End Sub
    Sub AgentsinSelection()
    '
    ' AgentsinSelection Macro
    '
    Dim Count As Integer
    Dim i As Integer

    For i = 18 To 189 Step 9

    If Sheet2.Cells(i, 6) > 0 Then
    Count = Count + 1
    End If

    Next i

    Sheet2.Cells(7, 11) = Count

    End Sub

    Now these are the various attempts at auto calculating.

    Private Sub Workbook_Open()

    End Sub



    Sub Calculate()
    '
    ' Calculate Macro
    ' Final Calculation of all Macro's
    '

    '
    Application.Run "'Direct Marketing QA Scoring Tool.xlsm'!AgentsinSelection"
    Application.Run "'Direct Marketing QA Scoring Tool.xlsm'!BenefitsandCovers"
    Application.Run "'Direct Marketing QA Scoring Tool.xlsm'!Closings"
    Application.Run _
    "'Direct Marketing QA Scoring Tool.xlsm'!ConditionsandExclusions"
    Application.Run "'Direct Marketing QA Scoring Tool.xlsm'!DeviationfromScript"
    Application.Run _
    "'Direct Marketing QA Scoring Tool.xlsm'!FinancialNeedsAnalysis"
    Application.Run _
    "'Direct Marketing QA Scoring Tool.xlsm'!PolicyDocumentandCoolingOff"
    Application.Run "'Direct Marketing QA Scoring Tool.xlsm'!InformationGiven"
    Application.Run "'Direct Marketing QA Scoring Tool.xlsm'!Termination"
    End Sub



    Anyone who could assist me with this, it would be most appreciated.

    Chenj.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Auto Calculate Macros when worksheet data updated or changes in multiple cells

    Put this formula in Sheet2 cell P2 and copy\drag down to P10
    =SUM(F18,F27,F36,F45,F54,F63,F72,F81,F90,F99,F108,F117,F126,F135,F144,F153,F162,F171,F180,F189)

    Put this in cell L7
    =COUNT(F18,F27,F36,F45,F54,F63,F72,F81,F90,F99,F108,F117,F126,F135,F144,F153,F162,F171,F180,F189)

    They would update as the data updates.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Valued Forum Contributor fredlo2010's Avatar
    Join Date
    07-04-2012
    Location
    Miami, United States
    MS-Off Ver
    Excel 365
    Posts
    762

    Re: Auto Calculate Macros when worksheet data updated or changes in multiple cells

    Hi,

    You can use "Call" Statement to run the different part of the code. Also the code looks a little complicated and repetitive. I would say it can be optimized but its hard to tell without the file.

    And last please use the # tags around your text to improve readability.

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How do I cause my macro to 'auto-update' whenever linked cells are updated??
    By Scottie in BKK in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-06-2012, 05:26 PM
  2. Worksheet Calculate Event tied to linked information that needs to be updated
    By siray13 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-08-2012, 07:28 PM
  3. Auto populate data from multiple cells on separate worksheet
    By Talance in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-01-2011, 07:19 PM
  4. [UPDATED] excel 2007 worksheet to HTML website. auto refresh/calculate?
    By astar24 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-13-2009, 12:11 PM
  5. Rev. Auto Updated when sheet is updated and or entire book
    By frankee_gee in forum Excel General
    Replies: 1
    Last Post: 04-07-2008, 05:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1