Consulting

Results 1 to 7 of 7

Thread: Solved: Error: 1004 - Application-defined...

  1. #1

    Solved: Error: 1004 - Application-defined...

    I get this error:
    Run-Time Error '1004':
    
    Application-defined or object-defined error
    When trying to run this code:
    Private Sub nGrade()
        Dim currentGrade, nextGrade As Integer
            Select Case Sheets("Final Grade Sheet").Range("J12").Value
                Case "Fail"
                    currentGrade = Sheets("Final Grade Sheet").Range(E15)
                Case "PM"
                    currentGrade = Sheets("Final Grade Sheet").Range("E16")
                Case "MM"
                    currentGrade = Sheets("Final Grade Sheet").Range("E17")
                Case "MD"
                    currentGrade = Sheets("Final Grade Sheet").Range("E18")
            End Select
            nextGrade = currentGrade - Sheets("Final Grade Sheet").Range("K9")
        Sheets("Marks Sheet").Range("P1").Value = nextGrade
    End Sub
    I have added a msgbox in multiple places and it seems to not display when I put it under the "Select Case" function.

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Private Sub nGrade()
    Dim currentGrade, nextGrade As Integer
    Select Case Sheets("Final Grade Sheet").Range("J12").Value
    Case "Fail"
    currentGrade = Sheets("Final Grade Sheet").Range("E15")
    Case "PM"
    currentGrade = Sheets("Final Grade Sheet").Range("E16")
    Case "MM"
    currentGrade = Sheets("Final Grade Sheet").Range("E17")
    Case "MD"
    currentGrade = Sheets("Final Grade Sheet").Range("E18")
    End Select
    nextGrade = currentGrade - Sheets("Final Grade Sheet").Range("K9")
    Sheets("Marks Sheet").Range("P1").Value = nextGrade
    End Sub
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    Errmm, I really doubt that changing the indenting will change anything or fix the error... and it hasn't...

  4. #4
    Never mind, fixed it my self.. :/

  5. #5
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by martynball
    Errmm, I really doubt that changing the indenting will change anything or fix the error... and it hasn't...
    You are joking aren't you, you don't really think that I just changed the indenting?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  6. #6
    Well, that's what I thought at first. I was like "What the hell... he has just changed the indenting". But I just compared them again and noticed the quotes, because like time I didnt see them.

    My mistake, sorry. I have fixed it now anyway. Cheers though

  7. #7
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    I didn't even change the indenting, that was done because you used [code] tags and I used [vba] tags.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

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