When this event is triggered, I get a message "Object or Library Not Found" as if it is looking for the VBA Object library, which should have been loaded. The worksheet name is "Input|Output". Is there a conflict between two events? I attached the code below for help Thanks!
Private Sub Worksheet_Activate()
'
Dim quote As String
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Application.EnableEvents = False
quote = Chr(34)
'if the system of units is US, update the formula for US units. This step is needed regardless of system.
If ActiveWorkbook.Worksheets("Input|Output").Range("I19").Value = "US" Then
Range("C5").Formula = "=IF('Input|Output'!I17=" & quote & "ADF" & quote & ",'Input|Output'!B28,'Input|Output'!B29)"
Else:
'if SI units are selected, convert MLD to m³/d by multiplying by 10^6/10^3 = 10^3
Range("D5").Formula = "=IF('Input|Output'!I17=" & quote & "ADF" & quote & ",'Input|Output'!I28*1000,'Input|Output'!I29*1000)"
End If
'if the system is not MBR, end the procedure here so that MOS tank dimensions are not carried over
'If ActiveWorkbook.Worksheets("Input|Output").Range("I18").Value = "no" Then
' Application.ScreenUpdating = True
' Application.EnableEvents = True
' Exit Sub
'End If
'units, MBR (yes/no), chemical P and RAS
Range("units").Formula = "=IO_Units"
Range("MBR").Formula = "=IO_MBR"
Range("Pr").Formula = "=IO_Pr"
Range("H4").Formula = "='Input|Output'!I15"
'check if MBR is yes; if so, update the tank formula, otherwise use that as rearation tank.
If ActiveWorkbook.Worksheets("Input|Output").Range("I18").Value = "yes" Then
'if US units are required, use MOS tank dimensions in ft
If ActiveWorkbook.Worksheets("Input|Output").Range("I19").Value = "US" Then
'tank length
Range("E96").Formula = "='Input|Output'!B38"
'tank width
Range("E97").Formula = "='Input|Output'!B39"
'water depth
Range("E98").Formula = "='Input|Output'!B40"
Else: 'if SI units are required, use MOS tank dimensions in m
'tank length
Range("F96").Formula = "='Input|Output'!I38"
'tank width
Range("F97").Formula = "='Input|Output'!I39"
'water depth
Range("F98").Formula = "='Input|Output'!I40"
End If
End If
'update formulas for influent water quality parameters
Range("C6").Formula = "=IO_Inf_BOD_Conc"
Range("C7").Formula = "=IO_Inf_TSS_Conc"
Range("C8").Formula = "=IO_Inf_Ammonia_Conc"
Range("C9").Formula = "=IO_Inf_TKN_Conc"
Range("C10").Formula = "=IO_Inf_Nitrate_Conc"
Range("C11").Formula = "=IO_Inf_TN_Conc"
Range("C12").Formula = "=IO_Inf_TP_Conc"
Range("C13").Formula = "=IO_Inf_Alk_Conc"
'update formulas for effluent water quality parameters
Range("C16").Formula = "=IO_Eff_BOD_Conc"
Range("C17").Formula = "=IO_Eff_TSS_Conc"
Range("C18").Formula = "=IO_Eff_Ammonia_Conc"
Range("C19").Formula = "=IO_Eff_TKN_Conc"
Range("C20").Formula = "=IO_Eff_Nitrate_Conc"
Range("C21").Formula = "=IO_Eff_TN_Conc"
Range("C23").Formula = "=IO_Eff_TP_Conc"
'new code Nov 2010
'==========================
'if check box to override formula is true, don't update
If chkRASOverride.Value = False Then
Range("RASREC").Formula = "=IF(MBR=" & quote & "yes" & quote & ",IF('Input|Output'!I17=" & quote & "ADF" & quote & ",'Input|Output'!B36,'Input|Output'!B37)/100,1)"
End If
'==========================
'site conditions and RAS rate
Range("Elevation").Formula = "=IO_Elevation_US"
Range("Elevation_SI").Formula = "=IO_Elevation_SI"
'Range("Flow").Select
'new code December 2010===================================
'design & minimum temperatures
Range("Design_Temp").Formula = "=IO_Design_Temp"
Range("Min_Temp").Formula = "=IO_Min_Temp"
Range("F31").Formula = "=32+(1.8*Design_Temp)"
Range("F32").Formula = "=32+(1.8*Min_Temp)"
'new code December 2010===================================
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub
Private Sub Worksheet_Activate()
'
Dim quote As String
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Application.EnableEvents = False
quote = Chr(34)
'if the system of units is US, update the formula for US units. This step is needed regardless of system.
If ActiveWorkbook.Worksheets("Input|Output").Range("I19").Value = "US" Then
Range("C5").Formula = "=IF('Input|Output'!I17=" & quote & "ADF" & quote & ",'Input|Output'!B28,'Input|Output'!B29)"
Else:
'if SI units are selected, convert MLD to m³/d by multiplying by 10^6/10^3 = 10^3
Range("D5").Formula = "=IF('Input|Output'!I17=" & quote & "ADF" & quote & ",'Input|Output'!I28*1000,'Input|Output'!I29*1000)"
End If
'if the system is not MBR, end the procedure here so that MOS tank dimensions are not carried over
'If ActiveWorkbook.Worksheets("Input|Output").Range("I18").Value = "no" Then
' Application.ScreenUpdating = True
' Application.EnableEvents = True
' Exit Sub
'End If
'units, MBR (yes/no), chemical P and RAS
Range("units").Formula = "=IO_Units"
Range("MBR").Formula = "=IO_MBR"
Range("Pr").Formula = "=IO_Pr"
Range("H4").Formula = "='Input|Output'!I15"
'check if MBR is yes; if so, update the tank formula, otherwise use that as rearation tank.
If ActiveWorkbook.Worksheets("Input|Output").Range("I18").Value = "yes" Then
'if US units are required, use MOS tank dimensions in ft
If ActiveWorkbook.Worksheets("Input|Output").Range("I19").Value = "US" Then
'tank length
Range("E96").Formula = "='Input|Output'!B38"
'tank width
Range("E97").Formula = "='Input|Output'!B39"
'water depth
Range("E98").Formula = "='Input|Output'!B40"
Else: 'if SI units are required, use MOS tank dimensions in m
'tank length
Range("F96").Formula = "='Input|Output'!I38"
'tank width
Range("F97").Formula = "='Input|Output'!I39"
'water depth
Range("F98").Formula = "='Input|Output'!I40"
End If
End If
'update formulas for influent water quality parameters
Range("C6").Formula = "=IO_Inf_BOD_Conc"
Range("C7").Formula = "=IO_Inf_TSS_Conc"
Range("C8").Formula = "=IO_Inf_Ammonia_Conc"
Range("C9").Formula = "=IO_Inf_TKN_Conc"
Range("C10").Formula = "=IO_Inf_Nitrate_Conc"
Range("C11").Formula = "=IO_Inf_TN_Conc"
Range("C12").Formula = "=IO_Inf_TP_Conc"
Range("C13").Formula = "=IO_Inf_Alk_Conc"
'update formulas for effluent water quality parameters
Range("C16").Formula = "=IO_Eff_BOD_Conc"
Range("C17").Formula = "=IO_Eff_TSS_Conc"
Range("C18").Formula = "=IO_Eff_Ammonia_Conc"
Range("C19").Formula = "=IO_Eff_TKN_Conc"
Range("C20").Formula = "=IO_Eff_Nitrate_Conc"
Range("C21").Formula = "=IO_Eff_TN_Conc"
Range("C23").Formula = "=IO_Eff_TP_Conc"
'new code Nov 2010
'==========================
'if check box to override formula is true, don't update
If chkRASOverride.Value = False Then
Range("RASREC").Formula = "=IF(MBR=" & quote & "yes" & quote & ",IF('Input|Output'!I17=" & quote & "ADF" & quote & ",'Input|Output'!B36,'Input|Output'!B37)/100,1)"
End If
'==========================
'site conditions and RAS rate
Range("Elevation").Formula = "=IO_Elevation_US"
Range("Elevation_SI").Formula = "=IO_Elevation_SI"
'Range("Flow").Select
'new code December 2010===================================
'design & minimum temperatures
Range("Design_Temp").Formula = "=IO_Design_Temp"
Range("Min_Temp").Formula = "=IO_Min_Temp"
Range("F31").Formula = "=32+(1.8*Design_Temp)"
Range("F32").Formula = "=32+(1.8*Min_Temp)"
'new code December 2010===================================
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub