Excel 2007 - Worksheet Activate Event Problem

TriGuy51

New Member
Joined
Mar 23, 2010
Messages
25
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
 

Some videos you may like

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

venkat1926

Well-known Member
Joined
Aug 21, 2005
Messages
4,824
quoted from ref: excel vba - "Can't find Project or Library" for standard VBA functions - Stack Overflow
4down vote​
I had the same problem. This worked for me:

  • In VB go to Tools » References
  • Uncheck the library "Crystal Analysis Common Controls 1.0". Or any library.
  • Just leave these 5 references:
    1. Visual Basic For Applications (This is the library that defines the VBA language.)
    2. Microsoft Excel Object Library (This defines all of the elements of Excel.)
    3. OLE Automation (This specifies the types for linking and embedding documents and for automation of other applications and the "plumbing" of the COM system that Excel uses to communicate with the outside world.)
    4. Microsoft Office (This defines things that are common to all Office programs such as Command Bars and Command Bar controls.)
    5. Microsoft Forms 2.0 This is required if you are using a User Form. This library defines things like the user form and the controls that you can place on a form.
  • Then Save.


<tbody style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent;">
</tbody>

unquote
will this help?
 

Watch MrExcel Video

Forum statistics

Threads
1,090,491
Messages
5,414,861
Members
403,549
Latest member
CascadeDiver

This Week's Hot Topics

Top