PDA

View Full Version : Object required on .Find



apgibson
07-12-2019, 02:48 AM
Any help please
I am getting a Compile Object Required when running a .Find on the following
Data has been generated from a form and the code is within the form.
I have highlighted in blue where I get the error.


Dim MODATT As String
Dim SearchRange As Range
Dim searchcell As String
Dim NewModShort As String
Dim MakeVal As String
Dim ModVal As String
Dim mdAtt As String

Private Sub ADDPROD_Click()
Worksheets("SKU List").Activate
SKUNUMBER = Range("A1").End(xlDown).Value + 1
Range("A1").End(xlDown).Offset(1).Value = SKUNUMBER
MODATT = Make.Value & " " & Model.Value & " " & PS.Value & "PS"


With Worksheets("Model Att").Range("A1", Range("A1").End(xlDown))
Set mdAtt = .Find(What:=MODATT, LookIn:=xlValues)
If mdAtt Is Nothing Then
Range("A1").End(xlDown).Offset(1).Value = MODATT
MODATT.PutInClipboard
MsgBox "Please add " & MODATT & "to the Model Attributes (This has been copied, ready to paste)", , "Add Attribute"
ModShort
Else
ModShort
End If
End Sub

Thanks

apgibson
07-12-2019, 02:49 AM
I Have also used


With Worksheets("Model Att")
Set mdAtt = .Range("A1", .Range("A1").End(xlDown)).Find(What:=MODATT, LookIn:=xlValues)
If mdAtt Is Nothing Then

Artik
07-12-2019, 03:35 PM
The Find method returns a Range object (when found) or Nothing (if it does not find). You have an error in the mdAtt variable declaration. The type should be Range.

Artik