PDA

View Full Version : Solved: Error: 1004 - Application-defined...



martynball
04-27-2010, 02:08 PM
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.

Bob Phillips
04-27-2010, 02:11 PM
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

martynball
04-27-2010, 02:13 PM
Errmm, I really doubt that changing the indenting will change anything or fix the error... and it hasn't...

martynball
04-27-2010, 02:44 PM
Never mind, fixed it my self.. :/

Bob Phillips
04-27-2010, 04:09 PM
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?

martynball
04-27-2010, 04:25 PM
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 :)

Bob Phillips
04-27-2010, 11:52 PM
I didn't even change the indenting, that was done because you used [code] tags and I used [vba] tags.