Consulting

Results 1 to 6 of 6

Thread: Object required (Error 424)

  1. #1

    Question Object required (Error 424)

    Hey Guys,
    I have met the error when I run the code. Object required (Error 424)
    I have checked all the variables and they are all properly dimed.
    This code is designed to catch the sequential transactions for a bank. When there are a pair of sequential number in the same column (they are bold already), we would like to mark the larger one as "Dupe of ###".
    Please see the code as following:
    Thank you very much!
    ---------------------------------------------------------------------------------------------
    Sub Label()
    Dim j As Variant
    Dim Duplicate As Variant
    For j = 60000 To 2 Step -1
    Duplicate = Sheets("To_DD comparison").Cells(j, 10).Value
    If Duplicate.DisplayFormat.Font.Bold = True Then
    If Exist(Duplicate) And Exist(Duplicate - 1) Then
    Sheets("To_DD comparison").Cells(j, 17).Value = "Dupe of" & Duplicate - 1
    End If
    End If
    Next j
    End Sub
    
    Function Exist(intNum) As Boolean
    Exist = False
    lastrow = Sheets("To_DD comparison").Range("A60000").End(xlUp).Row
    For i = 2 To lastrow
    If intNum = Sheets("To_DD comparison").Cells(i, 10).Value Then
    Exist True
    End If
    Next
    End Function
    Last edited by Paul_Hossler; 01-24-2017 at 03:22 PM. Reason: Added [CODE] tags - please use the [#] icon

  2. #2
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    https://msdn.microsoft.com/en-us/lib.../ff838814.aspx

    DisplayFormat is Range object's property, not its value's.
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

  3. #3
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,726
    Location
            If Sheets("To_DD comparison").Cells(j, 10).Font.Bold = True Then
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  4. #4
    Thank you mancubus. I have updated the code as Paul suggested and code can run. However, nothing happened after.

  5. #5
    Hi Paul Thanks for your help! However, nothing happened after run the code. Is there anything else wrong with the code? Thanks


    Sub Label()
    Dim j As Variant
    Dim Duplicate As Variant
    For j = 60000 To 2 Step -1
    Duplicate = Sheets("To_DD comparison").Cells(j, 10).Value
    If Sheets("To_DD comparison").Cells(j, 10).Font.Bold = True Then
    If Exist(Duplicate) And Exist(Duplicate - 1) Then
    Sheets("To_DD comparison").Cells(j, 17).Value = "Dupe of" & Duplicate - 1
    End If
    End If
    Next j
    End Sub
    Function Exist(intNum) As Boolean
    Exist = False
    lastrow = Sheets("To_DD comparison").Range("A60000").End(xlUp).Row
    For i = 2 To lastrow
    If intNum = Sheets("To_DD comparison").Cells(i, 10).Value Then
    Exist True
    End If
    Next
    End Function
    Last edited by Paul_Hossler; 01-25-2017 at 09:33 AM. Reason: Added [CODE] tags AGAIN - please use the [#] icon to add [CODE] tags

  6. #6
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,726
    Location
    1. I added [CODE] tags AGAIN - please use the [#] icon to add [CODE] tags to format your macros

    2. Without something to test with there is NO way to see why the macro is not doing what you think it should do

    Click [Go Advanced] and use the paperclip icon to attach a small sample
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

Posting Permissions

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