Error with the below code "Can't find project or library"

GirishDhruva

Active Member
Joined
Mar 26, 2019
Messages
308
Hi Everyone,

I am working in a project and below is my complete code.

Code:
Option Explicit
Sub Try()
Dim TOrig As String, STMonth As Long, SCMonth As Long, ECMonth As Long
Dim I As Long, J As Long, CMon, cCol As Long
Dim lrow As Long
Dim add_month As String
 
add_month = InputBox("Insert the CURRENT month", "CURRENT month", "CURRENT month")
Worksheets("S_R").Range("CT3").Value = add_month
 
TOrig = "CV4"
 
STMonth = Month(CDate("1-" & Range(TOrig) & "-2019"))
On Error GoTo ExitA
ECMonth = Month(CDate("1-" & Range("CT3") & "-2019"))
On Error GoTo 0
For J = 5 To Cells(Rows.Count, "C").End(xlUp).Row
    SCMonth = Month(Cells(J, "C").Value)
    For I = 0 To 11
        If SCMonth = ECMonth And Day(Cells(J, "C").Value) = 1 Then Exit For
        CMon = Format(DateSerial(2019, SCMonth + I, 1), "mmm")
        cCol = Application.Match(CMon, Cells(Range(TOrig).Row, 1).Resize(1, 300), False)
        If Not IsError(cCol) Then
            If I = 0 Then
                Cells(J, cCol).Value = Application.EoMonth(Cells(J, "C").Value, 0) + 1 - Cells(J, "C").Value
            Else
                Cells(J, cCol).Value = Application.EoMonth(Cells(J, "C").Value, I) - Application.EoMonth(Cells(J, "C").Value, I - 1)
            End If
            Cells(J, cCol).NumberFormat = "0"
            If Month(CDate("1-" & CMon & "-2019")) = ECMonth Then
                Exit For
            End If
        End If
    Next I
Next J
 
lrow = Cells(Rows.Count, "C").End(xlUp).Row
With Worksheets("S_R")
    For I = 5 To lrow
        If .Cells(I, "CV").Value = "" Or .Cells(I, "CV").Value = " " Then
            .Cells(I, "CV").Value = "0"
        End If
        If .Cells(I, "CW").Value = "" Or .Cells(I, "CW").Value = " " Then
            .Cells(I, "CW").Value = "0"
        End If
        If .Cells(I, "CX").Value = "" Or .Cells(I, "CX").Value = " " Then
            .Cells(I, "CX").Value = "0"
        End If
        If .Cells(I, "CY").Value = "" Or .Cells(I, "CY").Value = " " Then
            .Cells(I, "CY").Value = "0"
        End If
        If .Cells(I, "CZ").Value = "" Or .Cells(I, "CZ").Value = " " Then
            .Cells(I, "CZ").Value = "0"
        End If
        If .Cells(I, "DA").Value = "" Or .Cells(I, "DA").Value = " " Then
            .Cells(I, "DA").Value = "0"
        End If
        If .Cells(I, "DB").Value = "" Or .Cells(I, "DB").Value = " " Then
            .Cells(I, "DB").Value = "0"
        End If
        If .Cells(I, "DC").Value = "" Or .Cells(I, "DC").Value = " " Then
            .Cells(I, "DC").Value = "0"
        End If
        If .Cells(I, "DD").Value = "" Or .Cells(I, "DD").Value = " " Then
            .Cells(I, "DD").Value = "0"
        End If
        If .Cells(I, "DE").Value = "" Or .Cells(I, "DE").Value = " " Then
            .Cells(I, "DE").Value = "0"
        End If
        If .Cells(I, "DF").Value = "" Or .Cells(I, "DF").Value = " " Then
            .Cells(I, "DF").Value = "0"
        End If
        If .Cells(I, "DG").Value = "" Or .Cells(I, "DG").Value = " " Then
            .Cells(I, "DG").Value = "0"
        End If
    Next I
End With
 
With Range("DJ5:EM" & Range("D" & Rows.Count).End(xlUp).Row)
    .Formula = "=IF($CV5>0,ROUND((D5-AK5)*$CV5/30,0)-ROUND(((D5-AK5)*$CV5/30)*($BT5-$CG5)/30,0),0)+IF($CW5>0,ROUND((D5-AK5)*$CW5/31,0)-ROUND(((D5-AK5)*$CW5/31)*($BU5-$CH5)/31,0),0)+IF($CX5>0,ROUND((D5-AK5)*$CX5/30,0)-ROUND(((D5-AK5)*$CX5/30)*($BV5-$CI5)/30,0),0)+IF($CY5>0,ROUND((D5-AK5)*$CY5/31,0)-ROUND(((D5-AK5)*$CY5/31)*($BW5-$CJ5)/31,0),0)+IF($CZ5>0,ROUND((D5-AK5)*$CZ5/31,0)-ROUND(((D5-AK5)*$CZ5/31)*($BX5-$CK5)/31,0),0)+IF($DA5>0,ROUND((D5-AK5)*$DA5/30,0)-ROUND(((D5-AK5)*$DA5/30)*($BY5-$CL5)/30,0),0)+IF($DB5>0,ROUND((D5-AK5)*$DB5/31,0)-ROUND(((D5-AK5)*$DB5/31)*($BZ5-$CM5)/31,0),0)+IF($DC5>0,ROUND((D5-AK5)*$DC5/30,0)-ROUND(((D5-AK5)*$DC5/30)*($CA5-$CN5)/30,0),0)+IF($DD5>0,ROUND((D5-AK5)*$DD5/31,0)-ROUND(((D5-AK5)*$DD5/31)*($CB5-$CO5)/31,0),0)+IF($DE5>0,ROUND((D5-AK5)*$DE5/31,0)-ROUND(((D5-AK5)*$DE5/31)*($CC5-$CP5)/31,0),0)+IF($DF5>0,ROUND((D5-AK5)*$DF5/28,0)-ROUND(((D5-AK5)*$DF5/28)*($CD5-$CQ5)/28,0),0)+IF($DG5>0,ROUND((D5-AK5)*$DG5/31,0)-ROUND(((D5-AK5)*$DG5/31)*($CE5-$CR5)/31,0),0)"
    .Value = .Value
End With
 
ExitA:
End Sub

If i save this code in a workbook by assigning a button and once when i re-open the workbook it throws me an error called "Can't find project or library".

I even gone through many websites and searched for the solution but they mentioned to remove from references "Missing:Microsoft Excel Object Library" from the project, but i could't find any library in the name "Missing"

And my available references in the project are:
  • Visual Basic for Applications
  • Microsoft Excel 16.0 Object Library
  • OLE Automation
  • Microsoft Office 16.0 Object Library

I am using Microsoft Office 365


So please guide me where i am going wrong and should i need to make any changes in code or should i need to add some library to the project.


Regards,
Dhruva
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

Forum statistics

Threads
1,214,611
Messages
6,120,513
Members
448,967
Latest member
screechyboy79

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top