+ Reply to Thread
Results 1 to 8 of 8
  1. #1
    Registered User
    Join Date
    04-04-2009
    Location
    Nashville, TN,USA
    MS-Off Ver
    Excel 2007
    Posts
    78

    Problem with Date in macro

    Hello,

    I have a few macros that have a "Date" function in it for example,

    Code:
    IF Date => Sheets("Example").Range("A1") Then Something Happen
    My problem is that some of my end users are having a error upon running that code.

    A error box pops up and states that there is a compile error in a hidden module.

    I checked in to it on the computers that were having the issue and found the "Date" was the problem.

    Any suggestions as to how to fix it?????

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    MSO2007 on WinXP/MSO2000 on Win7
    Posts
    1,958

    Re: Problem with Date in macro

    Post the complete macro. Be sure to wrap it in code tags (use the "#" on the menu bar.)
    ---
    Ben Van Johnson

  3. #3
    Registered User
    Join Date
    04-04-2009
    Location
    Nashville, TN,USA
    MS-Off Ver
    Excel 2007
    Posts
    78

    Re: Problem with Date in macro

    Code:
    Sub Insurancejob()
    '
    ' insurancejob Macro
    '
    
    '
        If Range("S45") = "yes" Then
        Sheets("Information WS").Select
        ActiveSheet.Unprotect "9151"
        Range("C36").ClearContents
        Range("A1").Value = Date
        Range("F39:N39,F42:N42,F45:N45,F48:N48").Locked = False
        
        ActiveSheet.Protect "9151"
    
        priceupdater.Show
        Range("F20").Select
        
        Else
        
        Dim pageerror As String
        pageerror = MsgBox("Please Complete This Page", , "Page Error")
        
        
        End If
        
    End Sub
    Or another one that I have would be

    Code:
    Dim wks As Worksheet
    If Date >= Sheets("Error").Range("P1").Value Then
    
    Sheets("Error").Select
      expiredversion.Show

  4. #4
    Forum Guru
    Join Date
    01-03-2006
    Location
    Basingstoke, England
    MS-Off Ver
    2007 (work & home)
    Posts
    2,240

    Re: Problem with Date in macro

    Hi,

    I could be wrong but I think they may be missing a reference. In the VBE -Tools - References - tick "Visual basic For Applications".

    I'm basing this on the fact that if I press [F2] in the VBE to bring up the Object Browser, search for Date, and highlight the relevant row it states
    Property Date As Variant
    Member of VBA.DateTime
    If you then click on the hyperlink of the "VBA" section you are shown
    Library VBA
    C:\Program Files\Common Files\Microsoft Shared\VBA\VBA6\VBE6.DLL
    Visual Basic For Applications
    If you can't tick this option in the References dialog box, it may be "missing", in which case a quick Google search should help you.

    hth
    Rob
    Rob Brockett
    Kiwi in the UK
    Always learning & the best way to learn is to experience...

  5. #5
    Registered User
    Join Date
    04-04-2009
    Location
    Nashville, TN,USA
    MS-Off Ver
    Excel 2007
    Posts
    78

    Re: Problem with Date in macro

    The reference is there on the computer in which I am doing the programming. Perhaps it is not on the computers that are not. I will check and reply back soon. Thank you!

  6. #6
    Registered User
    Join Date
    04-04-2009
    Location
    Nashville, TN,USA
    MS-Off Ver
    Excel 2007
    Posts
    78

    Re: Problem with Date in macro

    OK, all of the computers that are having the problem seem to have the same settings as my own! Now I am really confused! Its not only this macro but popular ones like "SpellNumber" are not working on some computers as well.

  7. #7
    Forums Administrator royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    24,443

    Re: Problem with Date in macro

    In the VB Editor look at Tools-> References,if any have a X by themthen uncheck it.
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel consulting, free examples and tutorials visit Excel Consulting-Excel VBA
    Check out the free Excel Toolbar

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)


    Code Tags: Make your code easier for us to read

  8. #8
    Forum Moderator shg's Avatar
    Join Date
    06-21-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2007
    Posts
    25,134

    Re: Problem with Date in macro

    Microsoft MVP - Excel
    Entia non sunt multiplicanda sine necessitate

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.2.0