JoanaMartins
New Member
- Joined
- Jul 14, 2016
- Messages
- 29
Can anyone please tell me what i am doing wrong on my loop.
it goes on and on until it crashes excel.
i tried it in so many ways.
Can you help me please.
What I need it to do is to continue to find every w that is on the list.
Thank you in advance
it goes on and on until it crashes excel.
i tried it in so many ways.
Can you help me please.
What I need it to do is to continue to find every w that is on the list.
Thank you in advance
Code:
Sub tentativa()
Dim w As Range
Dim t As Long
Dim i As Long
Dim cs As Worksheet
Dim ps As Worksheet
Set cs = Sheets("Crono")
Set ps = Sheets("Projetos NOVO")
t = cs.Cells(cs.Rows.Count, 1).End(xlUp).Row
For i = 8 To t
Set w = ps.Range("C:C").Find(cs.Cells(i, 1).Value)
If Not (w Is Nothing) Then
Do
If InStr(1, w.Offset(0, 1).Value, cs.Cells(i, 3).Value, vbTextCompare) > 0 Then
cs.Cells(i, 4).Value = w.Offset(0, 15).Value
cs.Cells(i, 5).Value = w.Offset(0, 16).Value
End If
Loop While Not w Is Nothing
End If
Next i
End Sub