+ Reply to Thread
Results 1 to 7 of 7

Runtime error 13

Hybrid View

  1. #1
    Registered User
    Join Date
    12-21-2009
    Location
    Steveange
    MS-Off Ver
    Excel 2003
    Posts
    3

    Runtime error 13

    Hi,

    I keep getting a 'runtime error 13 type mismatch' error when running a macro in excel 2003 SP3, i cant see nothing wrong with the scripting when i click on 'debug' can anyone spot what i am doing wrong ? here is the higlighted error

    i am running windows xp sp3 and office version 2003 sp3

    please see below

    ------------------------------------------------
    Private Sub UserForm_Activate()
         'Set the form changer to change this userform
        Set oFormChanger.Form = Me
        oFormChanger.Modal = False
        oFormChanger.Sizeable = False
        oFormChanger.ShowCaption = True
        oFormChanger.ShowSysMenu = False
        oFormChanger.ShowTaskBarIcon = True
        oFormChanger.SmallCaption = True
        oFormChanger.ShowIcon = True
        oFormChanger.ShowCloseBtn = True
        oFormChanger.ShowMaximizeBtn = True
        oFormChanger.ShowMinimizeBtn = True
       OptionButton1.Value = True
        'By Air
        OptionButton1.Value = True
        If Range("DB_TravelFrom").Value = 1 Then
             If Range("DB_Air_London").Value = "not avail" And _
                Range("DB_Air_Stansted").Value = "not avail" And _
                Range("DB_Air_Luton").Value = "not avail" Then            
                OptionButton3.Enabled = False
                OptionButton3.Caption = "Air N/A"
            Else
                If Range("DB_Air_London").Value <> "not avail" Or _
                    Range("DB_Air_Stansted").Value <> "not avail" Or _
                    Range("DB_Air_Luton").Value <> "not avail" Then
                    OptionButton3.Caption = "Air"
                End If
            End If
        End If
        If Range("DB_TravelFrom").Value = 2 Then
            If Range("DB_Air_Manch").Value = "not avail" Then
                OptionButton3.Enabled = False
                OptionButton3.Caption = "Air N/A"
            End If
        End If
        If Range("DB_TravelFrom").Value = 3 Then
            If Range("DB_Air_Bris").Value = "not avail" Then
                OptionButton3.Enabled = False
                OptionButton3.Caption = "Air N/A"
            End If
        End If
        
        'By Rail
        If Range("DB_TravelFrom").Value = 1 Then
            If Range("DB_Rail_Stev").Value = "not avail" Then
                OptionButton2.Enabled = False
                OptionButton2.Caption = "Rail N/A"
            Else
                If Range("DB_Rail_Stev").Value <> "not avail" Then
                    OptionButton2.Enabled = True
                    OptionButton2.Caption = "Rail"
                End If
            End If
        End If
        If Range("DB_TravelFrom").Value = 2 Then
            If Range("DB_Rail_Lost").Value = "not avail" Then
                OptionButton2.Enabled = False
                OptionButton2.Caption = "Rail N/A"
            Else
                If Range("DB_Rail_Lost").Value <> "not avail" Then
                    OptionButton2.Enabled = True
                    OptionButton2.Caption = "Rail"
                End If
            End If
        End If
        If Range("DB_TravelFrom").Value = 3 Then
            If Range("DB_Rail_Filt").Value = "not avail" Then
                OptionButton2.Enabled = False
                OptionButton2.Caption = "Rail N/A"
            Else
                If Range("DB_Rail_Filt").Value <> "not avail" Then
                    OptionButton2.Enabled = True
                    OptionButton2.Caption = "Rail"
                End If
            End If
       End If
                
    End Sub
    Last edited by Leith Ross; 12-21-2009 at 12:14 PM. Reason: Added Code Tags

  2. #2
    Forum Contributor
    Join Date
    09-22-2009
    Location
    Indianapolis, Indiana
    MS-Off Ver
    Office 2003 / Office 2007
    Posts
    114

    Re: Runtime error 13 in Excel 2003 SP3, what am i doing wrong ?

    From my testing, you can not refer to a named range which includes multiple cells in a conditional statement. You have to specify which cell you want to test.

    If Range("MyRange").Cells(1, 1).Value = "Test"
    In this example, I've referenced the first cell in the range (which I set as a multidimensional named range on the sheet).

  3. #3
    Forum Contributor
    Join Date
    04-21-2007
    Location
    Lima, Peru
    MS-Off Ver
    2000, 2007, 2010
    Posts
    674

    Re: Runtime error 13 in Excel 2003 SP3, what am i doing wrong ?

    Hi

    It depends upon the value of the range being compared, e.g. comparing a number to a string will throw an error, or if the range has an error value that will cause an error to show as well.

    What are the value of the ranges being compared?

    Regards

    Jeff

  4. #4
    Registered User
    Join Date
    12-21-2009
    Location
    Steveange
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Runtime error 13 in Excel 2003 SP3, what am i doing wrong ?

    i didnt actually write this i'm trying to solve a company problem

    this is the error thats thrown up, the problem is that some users can use it fine and other other get the run time error

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Runtime error 13 in Excel 2003 SP3, what am i doing wrong ?

    Hello selbo81.

    To make your posts easier to read, copy, and edit please wrap your code. I did it for you this time. Here is how you can do it next time.

    How to wrap your Code
    1. Select all your code using the mouse.
    2. Click on the # icon on the toolbar in the Message window. This will automatically wrap the text you selected with the proper Code tags to create a Code Window in your post.
    3. To do it manually...
    Use the Bulletin Board Code Tags
    [code] at the start of the first line,
    [/code] at the end of the last line.


    To learn more about BB codes used in this forum, just click on the link below...

    Bulletin Board Codes Tags
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  6. #6
    Registered User
    Join Date
    12-21-2009
    Location
    Steveange
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Runtime error 13 in Excel 2003 SP3, what am i doing wrong ?

    now no one can see what part of the code is wrong ??? i highlighted it in bold before
    Last edited by selbo81; 12-21-2009 at 12:30 PM.

  7. #7
    Forum Contributor
    Join Date
    09-22-2009
    Location
    Indianapolis, Indiana
    MS-Off Ver
    Office 2003 / Office 2007
    Posts
    114

    Re: Runtime error 13 in Excel 2003 SP3, what am i doing wrong ?

    Quote Originally Posted by selbo81 View Post
    now no one can see what part of the code is wrong ??? i highlighted it in bold before
    I posted an entire post, with the most likely explanation. Another poster added an alternative reason why it would fail.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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.6.0 RC 1