Results 1 to 13 of 13

Thread: ***Resolved***Format function causing probs in excel 97 VBA

  1. #1

    Thread Starter
    Hyperactive Member beasty1711's Avatar
    Join Date
    Mar 2001
    Posts
    418

    ***Resolved***Format function causing probs in excel 97 VBA

    im getting

    Compile Error:
    Can't Find Project Or Library

    from this line of code
    VB Code:
    1. MMO_FP.tv_ratings.Value = Format(Sheet6.Cells("c3").Value, 0)

    all i'm trying to do is take the decimal places off the number in cell C3

    any ideas?
    Last edited by beasty1711; Jan 23rd, 2003 at 10:29 AM.
    "...They even have the internet on computers..." :- Homer Simpson

    "Second Place is First Looser" :- No Fear

  2. #2
    Frenzied Member McGenius's Avatar
    Join Date
    Jan 2003
    Posts
    1,199
    In your case use this:
    MMO_FP.tv_ratings.Value = Format(Sheet6.Cells("c3").Value, "0")
    McGenius

  3. #3

    Thread Starter
    Hyperactive Member beasty1711's Avatar
    Join Date
    Mar 2001
    Posts
    418
    tried that, but it still comes up with the same error message with the format word highlighted....
    i'm on SP2 with excel aswell
    "...They even have the internet on computers..." :- Homer Simpson

    "Second Place is First Looser" :- No Fear

  4. #4
    Fanatic Member joltremari's Avatar
    Join Date
    Sep 2000
    Location
    Mississippi
    Posts
    674
    Coudn't reproduce your error but try this:

    MMO_FP.tv_ratings.Value = Format(Sheet6.Cells(3, 3).Value, 0)



    JO
    "I have not failed. I've just found 10,000 ways that won't work."
    'Thomas Edison'

    "If we knew what it was we were doing it wouldn't be called research, would it?"
    'Albert Einstein'

    VB6

  5. #5
    Frenzied Member McGenius's Avatar
    Join Date
    Jan 2003
    Posts
    1,199
    Sorry, I mssed that error desc ... In Excel's VB Editor go to Tools > References and check if Visual Basic For application is selected.
    McGenius

  6. #6
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    Last time I saw this, it was because of a problem of "in"compatible version of (of all thins) the Common Control OCX (comctl.ocx)...... double check all your references. Make sure all is OK.
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  7. #7
    Frenzied Member TheBionicOrange's Avatar
    Join Date
    Apr 2001
    Location
    Cardiff, UK
    Posts
    1,818
    I'm presuming you are accessing Excel from VB.

    If so have you got the Excel library referenced in your project ?

  8. #8

    Thread Starter
    Hyperactive Member beasty1711's Avatar
    Join Date
    Mar 2001
    Posts
    418
    nah its an excel macro that was written in excel xp and now i have been given the nice job of debugging it for excel 97

    i've checked the referances and they all look fine

    the versions of the control are the same on my PC Excel xp and 97 and another PC which is 97 only
    "...They even have the internet on computers..." :- Homer Simpson

    "Second Place is First Looser" :- No Fear

  9. #9

    Thread Starter
    Hyperactive Member beasty1711's Avatar
    Join Date
    Mar 2001
    Posts
    418
    thats for everyones help
    but i managed to solve by doing
    VB Code:
    1. Range("c3").NumberFormat = "0"
    2. MMO_FP.tv_ratings.Value = Range("c3")

    i know its not the best way.. but afterall this is an excel macro.. and who said that macros were the best way :P
    "...They even have the internet on computers..." :- Homer Simpson

    "Second Place is First Looser" :- No Fear

  10. #10
    Frenzied Member McGenius's Avatar
    Join Date
    Jan 2003
    Posts
    1,199
    ... that was written in excel xp ...
    I see tons of problem now. That file should've been saved as Excel97 for compatibility.
    McGenius

  11. #11
    Frenzied Member TheBionicOrange's Avatar
    Join Date
    Apr 2001
    Location
    Cardiff, UK
    Posts
    1,818
    Instead of

    Code:
    MMO_FP.tv_ratings.Value = Format(Sheet6.Cells("c3").Value, 0)
    try ...

    Code:
    MMO_FP.tv_ratings.Value = Format(Sheet6.Range("c3").Value, 0)

  12. #12
    New Member
    Join Date
    Jul 2010
    Posts
    1

    Not Resolved

    I know this thread title says, resolved, but it looks like it was resolved by using different code, not by finding the root cause.

    I think I am having a similar same problem. I am running VBA for Excel 2007, although the files in question are saved as 97-2003 format.

    I have two identical pieces of code in two different excel files, one was copied from the other. In the code I use the "Format" function to convert a number to a string without the leading placeholder for sign.

    In the original file, this macro runs without any problems. In the copied version, VBA doesn't want to recognize the "Format" function. I get the following:
    Compile error:

    Wrong number of arguments or invalid property assignment
    When I look at the code, the "F" in format has been forced back to lower case, whereas in the original file it is forced to upper case indicating a recognized function.
    Both files have the same references selected.

    Anyone know why VBA would recognize the "Format" function in one excel file and not another?

    For reference, the line of code in question is:
    Code:
    If format(CSsht(CStar, 1)) = format(CSsht(CStar + 1, 1)) Then: GoTo FoundMatch
    Thanks for any help!

  13. #13
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: ***Resolved***Format function causing probs in excel 97 VBA

    Moved To Office Development

Posting Permissions

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



Click Here to Expand Forum to Full Width