PDA

View Full Version : Object required (Error 424)



Junji Qian
01-24-2017, 12:46 PM
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

mancubus
01-24-2017, 02:31 PM
https://msdn.microsoft.com/en-us/library/office/ff838814.aspx

DisplayFormat is Range object's property, not its value's.

Paul_Hossler
01-24-2017, 03:26 PM
If Sheets("To_DD comparison").Cells(j, 10).Font.Bold = True Then

Junji Qian
01-25-2017, 08:10 AM
Thank you mancubus. I have updated the code as Paul suggested and code can run. However, nothing happened after.

Junji Qian
01-25-2017, 08:17 AM
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

Paul_Hossler
01-25-2017, 09:36 AM
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