jeudi 14 juillet 2016

Simple code error for beginner - Excel VBA

My problem is:

  • I have 2 columns on sheet "Crono" that display an event and where it took place. I need to add two more columns with the start date and the end date of the event

The information is all on another sheet ("Projetos Novo"). The number of events is variable and that's why I created the variable i.

When I run the code it appears Run-time error '91': Object variable or With block variable not set

it actually copies the first six dates and then crashes.

I so need your kind help!!

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

`

Aucun commentaire:

Enregistrer un commentaire