Bonjour à tous,
Voilà je fais une petite macro, mais lors de l'execution une "erreur d'execution 1004" apparait...
je vous joint le code, l'erreur apparait sur la ligne Cells(20, 8).Formula = "=90-DEGRES(ATAN(" & r & "))"
Sub tire_vers_plaque()
Dim LastLine_couronne As Integer
Dim LastLine_plaque As Integer
Dim cel As Range
Dim i As Integer
Dim j As Integer
Dim max As Long
Dim min As Long
Dim alpha As Long
Dim x As Double
Dim y As Double
Dim r As Double
alpha = 0
LastLine_couronne = Range("A65536").End(xlUp).Row
LastLine_plaque = Range("E65536").End(xlUp).Row
MsgBox (LastLine_couronne & ";" & LastLine_plaque)
For i = 3 To LastLine_couronne
For Each cel In Union(Range("B3:B" & LastLine_couronne), Range("F3:F" & LastLine_plaque))
MsgBox ("1")
x = Cells(i, 3).Value - cel.Value
y = Cells(i, 4) - Cells(cel.Row, cel.Column + 1)
MsgBox (x & "_" & y & "___" & r)
If x > 0 Then
r = y / x
MsgBox ("2")
Cells(20, 8).Formula = "=90-DEGRES(ATAN(" & r & "))"
ElseIf x < 0 Then
r = y / x
MsgBox ("3")
Cells(20, 8).Formula = "=270-DEGRES(ATAN(" & r & "))"
End If
MsgBox (Cells(20, 8).Value)
If alpha < Cells(20, 8) Then alpha = Cells(65000, 40)
MsgBox (alpha)
Next cel
Next i
End Sub
Je ne comprend pas pourquoi...
Si qqun peut m'aider,
merci d'avance.