# erro de definição de aplicativo ou de definição de objeto



## lu fim (Jun 28, 2016)

Olá, fiz uma parte do codigo em uma planilha separada pois a que é a planilha final está muito pesada com codigos. Na planilha separada o codigo roda perfeitamente, porém quando copio e colo na planilha final ela da um erro:


"erro de definição de aplicativo ou de definição de objeto - 1004"


Tentei pesquisar, mudar parametros mas nao consigo por nada desfazer este problema.


Segue o Codigo. ( o problema ocorre na linha em azul)


```
LR = Range("A" & Rows.Count).End(xlUp).Row
    
    For rw = 3 To LR
        If IsEmpty(Range("AW" & rw).Value) Then
            Range("AW" & rw).Value = Date
            Range("AW" & rw).Select
                With Selection.Interior
                    .ColorIndex = 15
                    .Pattern = xlSolid
                End With
        End If


       If Range("AW" & rw).Value >= Range("Q" & rw).Value Then
            Range("AZ" & rw).Value = Range("Q" & rw).Value - Choose(Weekday(Range("Q" & rw).Value), 3, 4, 4, 2, 2, 2, 2)
            Range("AZ" & rw).Select
                With Selection.Interior
                    .ColorIndex = 35
                    .Pattern = xlSolid
                End With
            
        ElseIf Range("AW" & rw).Value < Range("Q" & rw).Value Then
            Range("AZ" & rw).Value = Range("AW" & rw).Value
            Range("AZ" & rw).Select
                With Selection.Interior
                    .ColorIndex = 6
                    .Pattern = xlSolid
                 End With
    
        End If


        If Range("H" & rw).Value <> "" Then
            Range("BA" & rw).Select
            Range("BA" & rw).Value = "Data prazo já existente, Conferir."
           
        End If
    Next rw
```

Grato.


----------



## lu fim (Jun 28, 2016)

<body id="************" style="position: absolute; top: 0px; width: 1px; height: 1px; overflow: hidden; left: -1000px;">
0down votefavorite​I created a code in a separete excel because the main one is too heavy with codes. In the separete excel the code works perfectly, but when I copy it to the main excel, it keeps giving me this "Application-defined or Object-defined error."
I tryed changing some parameters, and searched for some answers but couldnt find anything.
The line where the code stops with the error is: Range("AZ" & rw).Value = Range("Q" & rw).Value - Choose(Weekday(Range("Q" & rw).Value), 3, 4, 4, 2, 2, 2, 2)
Code:
<code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit;">LR = Range("A" & Rows.Count).End(xlUp).Row

For rw = 3 To LR
If IsEmpty(Range("AW" & rw).Value) Then
Range("AW" & rw).Value = Date
Range("AW" & rw).Select
With Selection.Interior
.ColorIndex = 15
.Pattern = xlSolid
End With
End If

If Range("AW" & rw).Value >= Range("Q" & rw).Value Then
Range("AZ" & rw).Value = Range("Q" & rw).Value - Choose(Weekday(Range("Q" & rw).Value), 3, 4, 4, 2, 2, 2, 2)
Range("AZ" & rw).Select
With Selection.Interior
.ColorIndex = 35
.Pattern = xlSolid
End With

ElseIf Range("AW" & rw).Value < Range("Q" & rw).Value Then
Range("AZ" & rw).Value = Range("AW" & rw).Value
Range("AZ" & rw).Select
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With

End If

If Range("H" & rw).Value <> "" Then
Range("BA" & rw).Select
Range("BA" & rw).Value = "Date already exists, please consult."

End If
Next rw</code>Thank you




<tbody style="margin: 0px; padding: 0px; border: 0px;">

</tbody></body>

0down votefavorite​I created a code in a separete excel because the main one is too heavy with codes. In the separete excel the code works perfectly, but when I copy it to the main excel, it keeps giving me this "Application-defined or Object-defined error."
I tryed changing some parameters, and searched for some answers but couldnt find anything.
The line where the code stops with the error is: Range("AZ" & rw).Value = Range("Q" & rw).Value - Choose(Weekday(Range("Q" & rw).Value), 3, 4, 4, 2, 2, 2, 2)
Code:
<code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit;">LR = Range("A" & Rows.Count).End(xlUp).Row

For rw = 3 To LR
If IsEmpty(Range("AW" & rw).Value) Then
Range("AW" & rw).Value = Date
Range("AW" & rw).Select
With Selection.Interior
.ColorIndex = 15
.Pattern = xlSolid
End With
End If

If Range("AW" & rw).Value >= Range("Q" & rw).Value Then
Range("AZ" & rw).Value = Range("Q" & rw).Value - Choose(Weekday(Range("Q" & rw).Value), 3, 4, 4, 2, 2, 2, 2)
Range("AZ" & rw).Select
With Selection.Interior
.ColorIndex = 35
.Pattern = xlSolid
End With

ElseIf Range("AW" & rw).Value < Range("Q" & rw).Value Then
Range("AZ" & rw).Value = Range("AW" & rw).Value
Range("AZ" & rw).Select
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With

End If

If Range("H" & rw).Value <> "" Then
Range("BA" & rw).Select
Range("BA" & rw).Value = "Date already exists, please consult."

End If
Next rw</code>Thank you




<tbody style="margin: 0px; padding: 0px; border: 0px;">

</tbody>


----------

