Runtime error '424' driving me nuts!!

JoanaMartins

New Member
Joined
Jul 14, 2016
Messages
29
Please, I so need your help!

The error appears when i do the set w thing!

I am kind of a beginner so can you kindly help me?

Code:
Sub Datas()

Dim w As Range
Dim t As Long
Dim i As Long




t = Sheets("Crono").Cells(Rows.Count, "A").End(xlUp).Row




For i = 8 To t


Set w = Sheets("Projetos NOVO").Range("C:C").Find(Sheets("Crono").Range("A" & i).Value).Row


If Sheets("Projetos NOVO").Range("D" & w).Find(Sheets("Crono").Range("C" & i).Value).Row Then


Sheets("Crono").Range("F" & i).Value = Sheets("Projetos NOVO").Range("R" & w).Value
Sheets("Crono").Range("G" & i).Value = Sheets("Projetos NOVO").Range("S" & w).Value


Else


End If


Next i


End Sub



Thank you in advance!
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Code:
Set w = Sheets("Projetos NOVO").Range("C:C").Find(Sheets("Crono").Range("A" & i).Value).Row

w is a Range
You're trying to assign a numeric value to it (.Row)

WBD
 
Upvote 0
But I need the number of the row because I use it below :(

If I change to this it happens error 91!

Can you please help?

Code:
Sub Datas()

Dim w As Long
Dim t As Long
Dim i As Long




t = Sheets("Crono").Cells(Rows.Count, "A").End(xlUp).Row




For i = 8 To t


w = Sheets("Projetos NOVO").Range("C:C").Find(Sheets("Crono").Range("A" & i).Value).Row


If Sheets("Projetos NOVO").Range("D" & w).Find(Sheets("Crono").Range("C" & i).Value).Row Then


Sheets("Crono").Range("F" & i).Value = Sheets("Projetos NOVO").Range("R" & w).Value
Sheets("Crono").Range("G" & i).Value = Sheets("Projetos NOVO").Range("S" & w).Value


Else


End If


Next i


End Sub
 
Upvote 0
Perhaps you're not dealing with the situation where the Find() doesn't actually find the text?

WBD
 
Upvote 0
You need to use the Set with .Find because it produces a range object. Objects require the use of Set. Once your range has been found then use w.Row
 
Upvote 0
I never thought of that but it might actually be true. because i don't want it to find the exact data that is on the cell but that it contains that text.

I thought that the .find() did that. Maybe I am wrong :s
 
Upvote 0
Like this?

Code:
Sub Datas()

Dim w As Range
Dim j As Long
Dim t As Long
Dim i As Long




t = Sheets("Crono").Cells(Rows.Count, "A").End(xlUp).Row




For i = 8 To t


Set w = Sheets("Projetos NOVO").Range("C:C").Find(Sheets("Crono").Range("A" & i).Value)


j = w.Row


If Sheets("Projetos NOVO").Range("D" & j).Find(Sheets("Crono").Range("C" & i).Value).Row Then


Sheets("Crono").Range("F" & i).Value = Sheets("Projetos NOVO").Range("R" & j).Value
Sheets("Crono").Range("G" & i).Value = Sheets("Projetos NOVO").Range("S" & j).Value


Else


End If


Next i


End Sub
 
Upvote 0
Heres an example of .Find with various variables

Code:
Set myFind = Sheets(counter).Cells.Find(What:=datatoFind, LookIn:=xlFormulas, LookAt:=xlPart, MatchCase:=False)
 
Upvote 0
Try like this:

Code:
Set w = Sheets("Projetos NOVO").Range("C:C").Find(What:=Sheets("Crono").Range("A" & i).Value, _
    LookIn:=xlFormulas, LookAt:=xlPart, MatchCase:=False)
If Not w Is Nothing Then
    j = w.Row
    MsgBox j
End If
 
Upvote 0

Forum statistics

Threads
1,214,614
Messages
6,120,519
Members
448,968
Latest member
Ajax40

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top