Announcement

Collapse
No announcement yet.

Unconfigured Ad Widget

Collapse

Fix run-time error '424': Object required in Excel VBA

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Fix run-time error '424': Object required in Excel VBA

    I am working on an Excel Userform to capture transport jobs performed each day. However, I am having a problem in the code with run-time error. I will appreciate it if someone can help me fix the error in the attached Excel document.

    Thanks much.TransLocDB.xlsTransLocDB.xls

  • #2
    Re: Fix run-time error '424': Object required in Excel VBA

    You don't have a form called frmDate.

    The form in your file is called frmTrans.
    Boo!

    Comment


    • #3
      Re: Fix run-time error '424': Object required in Excel VBA

      Norie, I changed it from frmTrans to frmDate thinking that was the problem. However, it did not solve the run-time error 424 in the code.

      Comment


      • #4
        Re: Fix run-time error '424': Object required in Excel VBA

        The object required error is because you have cEquipment instead of cEquip here.

        Code:
        For Each cEquip In ws.Range("EquipmentList")
          With Me.cboEquipment
            .AddItem cEquipment.Value
            .List(.ListCount - 1, 1) = cEquipment.Offset(0, 1).Value
          End With
        Next cEquip
        However that isn't the only problem.

        The combobox cboEquipment is already populated via it's RowSource property.

        There is no named range called 'LocationList'.

        Also, each of the comboboxes you are trying to populate from 'LocationList' are already populated by their RowSource property.
        Boo!

        Comment


        • #5
          Re: Fix run-time error '424': Object required in Excel VBA

          wow, I like the way you break down the problem with the code. As I am a beginner with VBA, formatting the code to get rid of the error is a challenge for me. If you can help me address these issues and attach the Excel file with these changes, I will appreciate it. Thanks much.

          Comment


          • #6
            Re: Fix run-time error '424': Object required in Excel VBA

            I can't really do that.

            For example, I don't know what LocationList should be or what it should be replaced with.

            I could guess, but that guess might be totally wrong and cause further problems.

            Perhaps you should just delete the code since the comboboxes are being populated without it anyway.
            Boo!

            Comment


            • #7
              Re: Fix run-time error '424': Object required in Excel VBA

              What I have is a LookupLists worksheet for the combo boxes. The whole goal of the LookupLists was developed for the combo boxes in the actual userform (for example, equipment combo box, select wheelchair or cart depending on what was used in performing the job from the equipment list). I did not set-up any LocationList in the file that was attached. Thanks a lot for your time on this.

              Comment


              • #8
                Re: Fix run-time error '424': Object required in Excel VBA

                If you have no LocationList and the comboboxes are getting populated fine without the code, which they are - I checked, then just delete the code.
                Boo!

                Comment


                • #9
                  Re: Fix run-time error '424': Object required in Excel VBA

                  The combo boxes are pulling those information from the LookupLists. That is why they are already populated when you view the userform in the object mode.

                  Comment


                  • #10
                    Re: Fix run-time error '424': Object required in Excel VBA

                    Norie, I changed the code as suggested and I am still getting the same error code. There must be something I am not doing right. Any assistance will be greatly appreciated. Thanks.

                    Comment


                    • #11
                      Re: Fix run-time error '424': Object required in Excel VBA

                      What changes did you make?

                      Can you post the workbook with the current code?
                      Boo!

                      Comment


                      • #12
                        Re: Fix run-time error '424': Object required in Excel VBA

                        I changed the line: Dim lDate As Long to Dim lTrans As Long.

                        When I ran the code, I received run-time error 70, permission denied. I have attached the workbook as requested. Thank you very much for your time.
                        Attached Files

                        Comment


                        • #13
                          Re: Fix run-time error '424': Object required in Excel VBA

                          Is that all you changed?

                          That wouldn't make any difference, and definitly wouldn't cause that error.

                          Did you not try what I suggested and remove these lines of code?
                          Code:
                          For Each cEquip In ws.Range("EquipmentList")
                            With Me.cboEquipment
                              .AddItem cEquip.Value
                              .List(.ListCount - 1, 1) = cEquipment.Offset(0, 1).Value
                            End With
                          Next cEquip
                          
                          For Each cComplStat In ws.Range("LocationList")
                            With Me.cboCompletionStatus
                              .AddItem cComplStat.Value
                            End With
                          Next cComplStat
                          
                          For Each cCancRea In ws.Range("LocationList")
                            With Me.cboCancellationReason
                              .AddItem cCancRea.Value
                            End With
                          Next cCancRea
                          
                          For Each cShf In ws.Range("LocationList")
                            With Me.cboShift
                              .AddItem cShf.Value
                            End With
                          Next cShf
                          Boo!

                          Comment


                          • #14
                            Re: Fix run-time error '424': Object required in Excel VBA

                            Wow,Norie, you are the best. The code is now working; Your suggestion to remove this part of the code actually did the magic.

                            For Each cEquip In ws.Range("EquipmentList") With Me.cboEquipment .AddItem cEquip.Value .List(.ListCount - 1, 1) = cEquipment.Offset(0, 1).Value End With Next cEquip For Each cComplStat In ws.Range("LocationList") With Me.cboCompletionStatus .AddItem cComplStat.Value End With Next cComplStat For Each cCancRea In ws.Range("LocationList") With Me.cboCancellationReason .AddItem cCancRea.Value End With Next cCancRea For Each cShf In ws.Range("LocationList") With Me.cboShift .AddItem cShf.Value End With Next cShf

                            Comment


                            • #15
                              Re: Fix run-time error '424': Object required in Excel VBA

                              Now that the userform is working, is there a code I can write to format time properly even if it was typed into the dispatch time dialogue box wrongly (such as 12:00pm instead of 12:00 p.m)? Also, is there a code to format lower case letters to upper case letters for "Dispatch By" and "To" on the userform? I also want to limit the "JOB ID" box to take 7 digits - anything less or more should flag error. Thank you very much for all your help. Truly appreciate it.

                              Comment

                              Trending

                              Collapse

                              There are no results that meet this criteria.

                              Working...
                              X