Consulting

Results 1 to 5 of 5

Thread: VBA on a MAC

  1. #1
    VBAX Expert
    Joined
    Feb 2005
    Posts
    929
    Location

    VBA on a MAC

    I recently ran several xls files on a MAC running Excel2011 (essentially xl2010 for a MAC) and found some strange differences:
    if a vbaproject is password protected on the PC, you can not view it on the MAC. The password is rejected as incorrect.
    One of the procedures I tested sequences down a tab doing different things depending on what it finds in Col 1. [vba]Menu_Number = MenuSheet.Cells(Row, 1).Value
    Select Case Menu_Number
    Case -1 ' end of useful data, cleanup and exit sub
    GoTo CleanUp
    Case 0 ' start of new menu
    [/vba] This procedure has run without error on several different computers running xl2000, xl2003, xl2007 and xl2010 over the last 10+ years. It fails on the MAC running xl2011. Is this possibly an example of the two systems (PC vs MAC) having slightly different "values" for "-1"
    "It's not just the due date that's important, it's also the do date" [MWE]

    When your problem has been resolved, mark the thread SOLVED by clicking on the Thread Tools dropdown menu at the top of the thread.

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    -1 is a MAC Boolean False. Use [VBA]Case Is = -1[/VBA]
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  3. #3
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,778
    Quote Originally Posted by SamT
    -1 is a MAC Boolean False. Use [VBA]Case Is = -1[/VBA]
    That is wrong. On a Mac, as on a PC, CLng(True) = -1 and CLng(False) = 0

    The possible sources of error that I see in that code is if the cell contains the string "-1" rather than the number -1.

    Or if the cell holds the logicals TRUE or FALSE and that is an attempt to test them.

  4. #4
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Then my memory is wrong, and I'm not going to search for the help file on it, because my solution is right.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  5. #5
    VBAX Expert
    Joined
    Feb 2005
    Posts
    929
    Location
    thanks for the suggestions. I modified the code to be more explicit, e.g., Case = -1 rather than Case -1. Turns out that the problem is even stranger than I thought. Either version of the code runs fine on the MAC as long as the project is not password protected. Further, if the code is password protected on a PC and then ported to a MAC, you can not view the project code because the MAC does not accept the password as valid.
    "It's not just the due date that's important, it's also the do date" [MWE]

    When your problem has been resolved, mark the thread SOLVED by clicking on the Thread Tools dropdown menu at the top of the thread.

Posting Permissions

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