Consulting

Results 1 to 7 of 7

Thread: Run Time Error 1004

  1. #1

    Run Time Error 1004

    Hey all,

    Runnng this code and getting a runtime error 1004 application defined or object defined error. I wouldve posted this in my other thread but couldnt unsolve the thread. Frustrated..it was working. It craps out when BX15 changes via drop down box. Every drop down selection causes the error

    thanks much

    [VBA]
    Sub Angelina()

    If Range("BX$15") = "A" And Range("F13") = 0 Or Range("BX$15") = "B" And Range("F13") = 0 Or Range("BX$15") = "C" And Range("F13") = 0 Or Range("BX$15") = "D" And Range("F13") = 0 Or Range("BX$15") = "E" And Range("F13") = 0 Or Range("BX$15") = "F" And Range("F13") = 0 Then
    Range("E13") = " "

    ElseIf Range("F13") >= 24 And Range("BX15") <> "A4" Then
    Range("E13") = "A"

    ElseIf Range("BX$15") = "B" Then
    Range("E13") = Range("$CF$16")

    ElseIf Range("BX$15") = "C" Then
    Range("E13") = Range("$CF$17")

    ElseIf Range("BX$15") = "D" Then
    Range("E13") = Range("$CQ$16")

    ElseIf Range("BX$15") = "E" Then
    Range("E13") = Range("$CQ$17")

    ElseIf Range("BX$15") = "F" Then
    Range("E13") = Range("$CQ$18")

    ElseIf Range("BX$15") = "G" Then
    Range("E13") = Range("$DC$14")

    End If
    End Sub
    [/VBA]

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Never a good idea to mix Ands and Ors without brackets.

    But try this alternative

    [vba]

    Sub Angelina()

    If Range("F13").Value2 = 0 Then

    If Range("BX$15") = "A" Or Range("BX$15") = "B" Or _
    Range("BX$15") = "C" Or Range("BX$15") = "D" Or _
    Range("BX$15") = "E" Or Range("BX$15") = "F" Then
    Range("E13") = ""
    End If

    ElseIf Range("F13") >= 24 And Range("BX15") <> "A4" Then
    Range("E13") = "A"

    ElseIf Range("BX$15") = "B" Then
    Range("E13") = Range("$CF$16")

    ElseIf Range("BX$15") = "C" Then
    Range("E13") = Range("$CF$17")

    ElseIf Range("BX$15") = "D" Then
    Range("E13") = Range("$CQ$16")

    ElseIf Range("BX$15") = "E" Then
    Range("E13") = Range("$CQ$17")

    ElseIf Range("BX$15") = "F" Then
    Range("E13") = Range("$CQ$18")

    ElseIf Range("BX$15") = "G" Then
    Range("E13") = Range("$DC$14")

    End If
    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
    XID,

    thanks..I like the code change.

    Still getting the runtime error. The error only happens when I change value in BX15 using a drop down box. When I open the workbook.. I enter a value in F13..Then select via drop down B. Thats where it craps out..see code marked in red. It will crap out no matter what selection I choose..if I choose C it will crap out in the line where C resides see green.

    thanks much

    [VBA]
    Sub Angelina()

    If Range("F13").Value2 = 0 Then

    If Range("BX$15") = "A" Or Range("BX$15") = "B" Or _
    Range("BX$15") = "C" Or Range("BX$15") = "D" Or _
    Range("BX$15") = "E" Or Range("BX$15") = "F" Then
    Range("E13") = ""
    End If

    ElseIf Range("F13") >= 24 And Range("BX15") <> "A4" Then
    Range("E13") = "A"

    ElseIf Range("BX$15") = "B" Then
    Range("E13") = Range("$CF$16")

    ElseIf Range("BX$15") = "C" Then
    Range("E13") = Range("$CF$17")

    ElseIf Range("BX$15") = "D" Then
    Range("E13") = Range("$CQ$16")

    ElseIf Range("BX$15") = "E" Then
    Range("E13") = Range("$CQ$17")

    ElseIf Range("BX$15") = "F" Then
    Range("E13") = Range("$CQ$18")

    ElseIf Range("BX$15") = "G" Then
    Range("E13") = Range("$DC$14")

    End If
    End Sub
    [/VBA]

  4. #4
    Ok...new info.

    When I have the sheet unprotected...everything works fine. When I protect the sheet...thats when I have the problems as described..

    didnt think protecting a sheet would cause a problem with this statement..anyways

    any ideas?

  5. #5
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    I cannot reproduce the error. Can you post your workbook?
    ____________________________________________
    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
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Just saw your last post. Unprotect it , so your stuff, protect it

    [vba]

    Sub Angelina()

    ActiveSheet.Unprotect Password:="abc"

    If Range("F13").Value2 = 0 Then

    If Range("BX$15") = "A" Or Range("BX$15") = "B" Or _
    Range("BX$15") = "C" Or Range("BX$15") = "D" Or _
    Range("BX$15") = "E" Or Range("BX$15") = "F" Then
    Range("E13") = ""
    End If

    ElseIf Range("F13") >= 24 And Range("BX15") <> "A4" Then
    Range("E13") = "A"

    ElseIf Range("BX$15") = "B" Then
    Range("E13") = Range("$CF$16")

    ElseIf Range("BX$15") = "C" Then
    Range("E13") = Range("$CF$17")

    ElseIf Range("BX$15") = "D" Then
    Range("E13") = Range("$CQ$16")

    ElseIf Range("BX$15") = "E" Then
    Range("E13") = Range("$CQ$17")

    ElseIf Range("BX$15") = "F" Then
    Range("E13") = Range("$CQ$18")

    ElseIf Range("BX$15") = "G" Then
    Range("E13") = Range("$DC$14")

    End If

    ActiveSheet.Protect Password:="abc"
    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

  7. #7
    Thanks XID..ill check this out tommorow

Posting Permissions

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