Mcottuli
asked on
Multiple VBS Macros running at once
I have an excel sheet that uses a VBS macro to update a sheet when a change is made on another sheet. This works fine, now I need to add an almost identical macro to the sheet that updates when different cells are changed. I actually need to add MANY of these MACROS. The problem I am having is that when I create and 2nd "Module" in the VBS editor and "RUN" the new macro it works fine, but when in the actual sheet itself, only the original macro seems to run. How can I get all my other Macros to kickoff when the first one does. Below is the VBS of the original and functioning Macro "Module1" and the bottom is the 2nd Module2 that does not work unless manually run.
Module1
Sub UpdateMonthlyTotals()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim ColumnNumber As Integer
Const StartYear = 2013
Const StartMonth = 9
Const StartRow = 15
Const StartColumn = 2
Const SourceRow = 142
Const SourceStartColumn = 3
Const NumberOfItems = 10
Dim CurrentYear As Integer
Dim CurrentMonth As Integer
Dim ItemNumber As Integer
Dim SourceCell As String
Dim TargetCell As String
Dim SourceValue As String
Dim SourceFormat As Variant
CurrentYear = Year(Now())
CurrentMonth = Month(Now())
ColumnNumber = (CurrentYear - StartYear) * 12 + (CurrentMonth - StartMonth) + StartColumn
For ItemNumber = 0 To NumberOfItems - 1
SourceCell = Chr(ItemNumber + 64 + SourceStartColumn) & Format(SourceRow, "0")
TargetCell = Chr(ColumnNumber + 64) & Format(StartRow + ItemNumber * 12 + 1)
Sheets("Scorecard").Select
SourceValue = Range(SourceCell).Value
SourceFormat = Range(SourceCell).NumberFo rmat
Sheets("Plan vs Actual").Select
Range(TargetCell).Value = SourceValue
Range(TargetCell).NumberFo rmat = SourceFormat
Next ItemNumber
Sheets("Scorecard").Select
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub
Module2
Sub UpdateERMMonthlyTotals()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim ColumnNumber As Integer
Const StartYear = 2013
Const StartMonth = 9
Const StartRow = 41
Const StartColumn = 2
Const SourceRow = 6
Const SourceStartColumn = 5
Const NumberOfItems = 1
Dim CurrentYear As Integer
Dim CurrentMonth As Integer
Dim ItemNumber As Integer
Dim SourceCell As String
Dim TargetCell As String
Dim SourceValue As String
Dim SourceFormat As Variant
CurrentYear = Year(Now())
CurrentMonth = Month(Now())
ColumnNumber = (CurrentYear - StartYear) * 12 + (CurrentMonth - StartMonth) + StartColumn
For ItemNumber = 0 To NumberOfItems - 1
SourceCell = Chr(ItemNumber + 64 + SourceStartColumn) & Format(SourceRow, "0")
TargetCell = Chr(ColumnNumber + 64) & Format(StartRow + ItemNumber * 1 + 1)
Sheets("Scorecard").Select
SourceValue = Range(SourceCell).Value
SourceFormat = Range(SourceCell).NumberFo rmat
Sheets("Plan vs Actual").Select
Range(TargetCell).Value = SourceValue
Range(TargetCell).NumberFo rmat = SourceFormat
Next ItemNumber
Sheets("Scorecard").Select
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub
Module1
Sub UpdateMonthlyTotals()
Application.ScreenUpdating
Application.Calculation = xlCalculationManual
Dim ColumnNumber As Integer
Const StartYear = 2013
Const StartMonth = 9
Const StartRow = 15
Const StartColumn = 2
Const SourceRow = 142
Const SourceStartColumn = 3
Const NumberOfItems = 10
Dim CurrentYear As Integer
Dim CurrentMonth As Integer
Dim ItemNumber As Integer
Dim SourceCell As String
Dim TargetCell As String
Dim SourceValue As String
Dim SourceFormat As Variant
CurrentYear = Year(Now())
CurrentMonth = Month(Now())
ColumnNumber = (CurrentYear - StartYear) * 12 + (CurrentMonth - StartMonth) + StartColumn
For ItemNumber = 0 To NumberOfItems - 1
SourceCell = Chr(ItemNumber + 64 + SourceStartColumn) & Format(SourceRow, "0")
TargetCell = Chr(ColumnNumber + 64) & Format(StartRow + ItemNumber * 12 + 1)
Sheets("Scorecard").Select
SourceValue = Range(SourceCell).Value
SourceFormat = Range(SourceCell).NumberFo
Sheets("Plan vs Actual").Select
Range(TargetCell).Value = SourceValue
Range(TargetCell).NumberFo
Next ItemNumber
Sheets("Scorecard").Select
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating
End Sub
Module2
Sub UpdateERMMonthlyTotals()
Application.ScreenUpdating
Application.Calculation = xlCalculationManual
Dim ColumnNumber As Integer
Const StartYear = 2013
Const StartMonth = 9
Const StartRow = 41
Const StartColumn = 2
Const SourceRow = 6
Const SourceStartColumn = 5
Const NumberOfItems = 1
Dim CurrentYear As Integer
Dim CurrentMonth As Integer
Dim ItemNumber As Integer
Dim SourceCell As String
Dim TargetCell As String
Dim SourceValue As String
Dim SourceFormat As Variant
CurrentYear = Year(Now())
CurrentMonth = Month(Now())
ColumnNumber = (CurrentYear - StartYear) * 12 + (CurrentMonth - StartMonth) + StartColumn
For ItemNumber = 0 To NumberOfItems - 1
SourceCell = Chr(ItemNumber + 64 + SourceStartColumn) & Format(SourceRow, "0")
TargetCell = Chr(ColumnNumber + 64) & Format(StartRow + ItemNumber * 1 + 1)
Sheets("Scorecard").Select
SourceValue = Range(SourceCell).Value
SourceFormat = Range(SourceCell).NumberFo
Sheets("Plan vs Actual").Select
Range(TargetCell).Value = SourceValue
Range(TargetCell).NumberFo
Next ItemNumber
Sheets("Scorecard").Select
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER