+ Reply to Thread
Results 1 to 9 of 9

Run-time error '424' Object Required

Hybrid View

  1. #1
    Registered User
    Join Date
    01-28-2015
    Location
    Johannesburg, South Africa
    MS-Off Ver
    2007 and 2010
    Posts
    6

    Run-time error '424' Object Required

    Hello everyone

    I'd like to say thanks in advance for any help.

    In my project I have a search function that has to search a row for a number and if the number is found, it should return all data written on the spreadsheet row to respective text and comboboxes on the userform, but I recieve a run-time error 424 object required error and the line that gets highlighted is *For each c in DataBase.range("C:C").cells* and I don't know why. Here is my piece of code below. DataBase is the name of the spreadsheet which must be searched and the searched numbers are always in column C. If a different approach can be used please help me with them. I hope I was clear enough.


    Private Sub cmdSearch_Click()
        
        For Each c In DataBase.Range("C:C").Cells
            If c.Value <> "" Then
                If cboJobCardNo.Value = c.Value Then
                
                    txtRequester.Value = c.Offset(0, -2).Value
                    txtDate.Value = c.Offset(0, -1).Value
                    cboDept.Value = c.Offset(0, 1).Value
                    cboFacility.Value = c.Offset(0, 2).Value
                    cboEquip.Value = c.Offset(0, 3).Value
                    cboItem.Value = c.Offset(0, 4).Value
                    cboProbType.Value = c.Offset(0, 5).Value
                    txtProbDescription.Value = c.Offset(0, 6).Value
                
                    MsgBox "Now you can update.", vbInformation, "UPDATE ENTRY"
                Else
                End If
            Else
            Exit Sub
            End If
        Next
    
    End Sub
    zbor I apologize for that...I thought using [code] before and after the code would work...I am still new so am really sorry.
    Last edited by Touch; 02-04-2015 at 07:40 AM. Reason: Solved

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,052

    Re: Run-time error '424' Object Required

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE] [/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Never use Merged Cells in Excel

  3. #3
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: Run-time error '424' Object Required

    Yea, what Norie said
    Last edited by gmr4evr1; 01-29-2015 at 10:50 AM. Reason: Changed my answer
    1N73LL1G3NC3 15 7H3 4B1L17Y 70 4D4P7 70 CH4NG3 - 573PH3N H4WK1NG
    You don't have to add Rep if I have helped you out (but it would be nice), but please mark the thread as SOLVED if your issue is resolved.

    Tom

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Run-time error '424' Object Required

    Try Sheets("Database").
    If posting code please use code tags, see here.

  5. #5
    Registered User
    Join Date
    01-28-2015
    Location
    Johannesburg, South Africa
    MS-Off Ver
    2007 and 2010
    Posts
    6

    Re: Run-time error '424' Object Required

    Hi Norie

    I have added that and I don't get the error message...but nothing is happening now, it doesn't complete the action... I don't know if I am missing something or I have coded it just wrong.. any idea how to go about with this? Please help

  6. #6
    Valued Forum Contributor
    Join Date
    11-26-2012
    Location
    Sydney
    MS-Off Ver
    2010
    Posts
    423

    Re: Run-time error '424' Object Required

    Is the first entry in column C blank? Without seeing the spreadsheet, it appears that the only ways for this code to do nothing is if that is the case, or if cboJobCardNo.Value = c.Value is never true.

  7. #7
    Registered User
    Join Date
    01-28-2015
    Location
    Johannesburg, South Africa
    MS-Off Ver
    2007 and 2010
    Posts
    6

    Re: Run-time error '424' Object Required

    Hi mgs73

    Yes you right the first entry is blank. The entries in column C start at the third row of C and on the second row I have the heading Job Card No.. Is there a way I could set the range to start on the second row?

  8. #8
    Valued Forum Contributor
    Join Date
    11-26-2012
    Location
    Sydney
    MS-Off Ver
    2010
    Posts
    423

    Re: Run-time error '424' Object Required

    Try this:
      Dim sh As Worksheet
      Dim LastRow As Long
      
      Set sh = ThisWorkbook.Worksheets("Database")
      LastRow = sh.Cells(sh.Rows.Count, "C").End(xlUp).Row
        
      For Each c In sh.Range(sh.Cells(3, 3).Address, sh.Cells(LastRow, 3).Address)

  9. #9
    Registered User
    Join Date
    01-28-2015
    Location
    Johannesburg, South Africa
    MS-Off Ver
    2007 and 2010
    Posts
    6

    Re: Run-time error '424' Object Required

    Yo

    mgs73 thank you a million and one times lOol, its working perfectly now...Thank you alot.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Simple Calendar pop up macro --> error Run-time error '424': Object required
    By am_hawk in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-11-2013, 10:38 AM
  2. VBA - “Run-time error 424: object required”
    By randiba in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-23-2013, 07:28 AM
  3. Run-Time error 424 - Object required
    By Mr_Knows_Nothing in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-04-2012, 01:19 PM
  4. Run-Time Error 424 - Object Required
    By SpottyTash in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-09-2005, 09:05 AM
  5. Run-time error '424': Object required
    By ez_cali in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 05-21-2005, 03:52 AM

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