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

lu fim

New Member
Joined
Jun 21, 2016
Messages
26
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)

Rich (BB code):
 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.
 
Last edited by a moderator:

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
<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>
 
Upvote 0

Forum statistics

Threads
1,214,932
Messages
6,122,332
Members
449,077
Latest member
jmsotelo

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