Notifications
Clear all

Reduzir tempo de processamento

2 Posts
2 Usuários
0 Reactions
1,341 Visualizações
(@jpfornari)
Posts: 43
Trusted Member
Topic starter
 

Boa Tarde!

Estou tentando simplificar meu código para ele fazer a função mais rápida, ele está pensando muito para exercer a mesma fica carregando uns 10seg!

Acredito que de para reduzir o tempo, acho que está em algum pequeno looping no IF:

Segue abaixo o comando!

Sub Botão150_Clique()

If MsgBox("DESEJA APAGAR TODOS OS DADOS", vbYesNo + vbQuestion, "LIMPAR DADOS") = vbYes Then

Range("B13:G162,I13:I162,L13:L162,A13:A162,M11:AA11, A2:B9").Select
Selection.ClearContents
ActiveCell.Select

For coluna = 1 To 1
For linha = 13 To 162
If Cells(linha, coluna).HasFormula = False Then
If Cells(linha, coluna) = Empty Then
Cells(linha, coluna) = "SELECIONE UM PAVIMENTO"
End If
End If
Next linha
Next coluna

For coluna = 13 To 27
For linha = 11 To 11
If Cells(linha, coluna).HasFormula = False Then
If Cells(linha, coluna) = Empty Then
Cells(linha, coluna) = "INFORME O REVESTIMENTO"
End If
End If
Next linha
Next coluna

Else

End If

End Sub

Se for possivel um ajuda com um mesmo comando só que mais rapido eu agradeço!!

Obrigado!

 
Postado : 01/11/2012 12:40 pm
(@fernandofernandes)
Posts: 43750
Illustrious Member
 

Boa tarde,

Acredito que o código abaixo faça o mesmo e, talvez, seja mais rápido:

Sub Botão150_Clique()
    If MsgBox("DESEJA APAGAR TODOS OS DADOS", vbYesNo + vbQuestion, "LIMPAR DADOS") = vbYes Then
        Range("B13:G162,I13:I162,L13:L162,A13:A162,M11:AA11, A2:B9").ClearContents
        Range("A13:A162").Value = "SELECIONE UM PAVIMENTO"
        Range("M11:AA11").Value = "INFORME O REVESTIMENTO"
    End If
End Sub

Abraço

 
Postado : 01/11/2012 3:08 pm