• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Format Dates Etc|VBA & Macros|Excel Forum|My Online Training Hub

You are here: Home / Format Dates Etc|VBA & Macros|Excel Forum|My Online Training Hub
Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search|Last Search Results
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumVBA & MacrosFormat Dates Etc
sp_PrintTopic sp_TopicIcon
Format Dates Etc
Avatar
Ivan Dammash

New Member
Members
Level 0
Forum Posts: 2
Member Since:
February 20, 2021
sp_UserOfflineSmall Offline
1
July 8, 2022 - 2:13 pm
sp_Permalink sp_Print

Hi,

This code was working fine previously but, now the Format statement generates a compiler error "Compile error: Can't find project or library". Has this been changed in vba?  FYI.This bit of code is called from a UserForm TextBox that requests a date, other information I use Excel 2019 and Windows 11.

Can anybody please assist as to why this code generate an error, I use the Day, Month and Year date format.

Private Sub tb_Date_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim TNumb, MyLastRow, MyN, NextTN As Long
Dim MyDate As Date                                                                             
Dim Response As VbMsgBoxResult
Dim Ed As String, Fd As String
Dim Admin As Worksheet
Set Admin = ThisWorkbook.Worksheets("Admin")
Ed = " The entered Date: "
Fd = " is in the future! Do you want to use that Date?"                                            
On Error GoTo ErrorHandler
MyDate = Me.tb_Date
On Error GoTo 0
'******* Check if the entered date is a future date ***************
If MyDate > Now() Then
Response = MsgBox("Today's date is: " & Format(Now(), "dd mmm yyyy") & Ed & Format(MyDate, "dd mmm yyyy") & Fd, vbYesNo +  vbDefaultButton2   + vbQuestion, "Future Date Entered")

   If Response = vbNo Then
      Me.tb_Date = ""
      Exit Sub
   End If
End If
'*******************************************************************
Me.tb_Date = Format(MyDate, "dd mmm yyyy")
Me.tbTransNum.Visible = True
Me.lblTransNo.Visible = True
'********** Set the next Transaction Number ************
TNumb = Admin.Cells(2, 2)
NextTN = TNumb + 1
Admin.Cells(2, 2) = NextTN
'*******************************************************
Me.tbTransNum = "TN" & NextTN
Me.lblTransFor.Visible = True
Me.OBtn_Tre.Visible = True
Me.OBut_Jill.Visible = True
Me.BtnSave.Visible = True
Exit Sub
ErrorHandler:
If Err = 13 Then
MsgBox "Date entered is not Valid! Please enter a valid date.", vbOKOnly
Me.tb_Date = ""
Exit Sub
End If

End Su

Avatar
Velouria
London or thereabouts
Moderator
Members


Trusted Members

Moderators
Level 4
Forum Posts: 648
Member Since:
November 1, 2018
sp_UserOfflineSmall Offline
2
July 8, 2022 - 5:55 pm
sp_Permalink sp_Print

You have a missing reference. With that project active in the VBE, click Tools - References and look for one (or more) of the checked references that has 'MISSING:' at the start of its name.

Avatar
Ivan Dammash

New Member
Members
Level 0
Forum Posts: 2
Member Since:
February 20, 2021
sp_UserOfflineSmall Offline
3
July 10, 2022 - 8:19 am
sp_Permalink sp_Print

Thank you Velouria That has fixed the problem.

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: ash seth, Cassie Bernier
Guest(s) 11
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 873
Purfleet: 414
Frans Visser: 346
David_Ng: 306
lea cohen: 222
Jessica Stewart: 215
A.Maurizio: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
Abisola Ogundele
MARTYN STERRY
Rahim Lakhani
Ngoc Qui Nguyen
Clement Mansfield
Rose .
Bindu Menon
Baruch Zemer
Purple RainbowBenefactor
MOTH Junkie
Forum Stats:
Groups: 3
Forums: 24
Topics: 6349
Posts: 27772

 

Member Stats:
Guest Posters: 49
Members: 32317
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.