Userform - Cannot Find Project Or Library

snuggles79

New Member
Joined
Sep 25, 2006
Messages
8
Yesterday my code in excel was working perfectly and today I am getting a "Cannot Find Project Or Library" error message and it's highlighting the phrase "Format" in particular

The code is:

Code:
Private Sub contdate_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    If Not IsDate(contdate) Then
        MsgBox "Input must be a date in the format: 'dd/mm/yyyy'"
        Cancel = True
    Else
        contdate = Format(contdate, "dd/mm/yyyy")
    End If
End Sub




Private Sub conttime_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    If Not IsDate(conttime) Then
        MsgBox "Input must be a time in the format: 'hh:mm'"
        Cancel = True
    Else
        conttime = Format(conttime, "hh:mm")
    End If
End Sub

Anybody know how to sort this problem out?

Thanks in advance
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

Richard Schollar

MrExcel MVP
Joined
Apr 19, 2005
Messages
23,707
Hi

Try preceding the Format with VBA ie:

Code:
contdate = VBA.Format(contdate, "dd/mm/yyyy")

Best regards

Richard
 

snuggles79

New Member
Joined
Sep 25, 2006
Messages
8
That's great and it now works perfectly - can you explain the logic behind having to do that all of a sudden though please and what it means exactly?
 

Richard Schollar

MrExcel MVP
Joined
Apr 19, 2005
Messages
23,707
Not sure why it would go all of a sudden, but presumably the compiler is looking for the Format method in eg the Forms library and not finding it. preceding by VBA tells it to look in the VBA library.

Richard
 

Forum statistics

Threads
1,141,678
Messages
5,707,782
Members
421,527
Latest member
Tamiwsw

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
Top