Este fórum está sendo desativado

Depois de 9 anos, este fórum será desativado. Mas calma.... estamos migrando para uma comunidade no DISCORD. Junte-se a nós.

ENTRAR PARA DISCORD

Tópicos relacionados a códigos VBA, gravação de macros, etc.
  • Avatar do usuário
Por Diego100ges
Posts
#56437
Boa tarde pessoal,

Fiz essa macro (em anexo) e está servindo bem, porém acho que daria pra melhorar um pouco o código.

sugestões?

desde já, obrigado!
Você não está autorizado a ver ou baixar esse anexo.
Avatar do usuário
Por mucascosta
Posts Avatar
#56511
Talvez possa diminuir o tem de execução da macro adicionando no inicio Application.Calculation = xlCalculationManual no final Application.Calculation = xlCalculationAutomatic

Sub TesteVelocidade()
Dim Tempo As Double
Tempo = Now()

'SUA MACRO

MsgBox Now() - Tempo
End Sub
Por osvaldomp
#56537
Experimente:
Código: Selecionar todos
Sub PontaOuForaPonta()
 Dim LR As Long
 Application.ScreenUpdating = False
 With ActiveSheet
  .AutoFilterMode = False
  LR = .Cells(Rows.Count, 1).End(3).Row
  .Range("J5:K" & LR) = ""
  .Range("K5:K" & LR).FormulaLocal = "=DIATRABALHO(B5-1;1;R$1:R$7)=B5"
  .Range("A4:K4").AutoFilter 3, ">=18", xlAnd, "<21"
  .Range("A4:K4").AutoFilter 11, "VERDADEIRO"
  .Range("J5:J" & LR) = "Ponta"
  .AutoFilterMode = False
  .Range("J5:J" & LR).SpecialCells(xlBlanks).Value = "Fora Ponta"
  .[K:K] = ""
 End With
End Sub
Coloque a lista dos feriados em R1:R7.
Por Diego100ges
Posts
#56959
@osvaldomp ficou incrivelmente mais rápido, ótimo mesmo, muito obrigado!
osvaldomp escreveu:Experimente:
Código: Selecionar todos
Sub PontaOuForaPonta()
 Dim LR As Long
 Application.ScreenUpdating = False
 With ActiveSheet
  .AutoFilterMode = False
  LR = .Cells(Rows.Count, 1).End(3).Row
  .Range("J5:K" & LR) = ""
  .Range("K5:K" & LR).FormulaLocal = "=DIATRABALHO(B5-1;1;R$1:R$7)=B5"
  .Range("A4:K4").AutoFilter 3, ">=18", xlAnd, "<21"
  .Range("A4:K4").AutoFilter 11, "VERDADEIRO"
  .Range("J5:J" & LR) = "Ponta"
  .AutoFilterMode = False
  .Range("J5:J" & LR).SpecialCells(xlBlanks).Value = "Fora Ponta"
  .[K:K] = ""
 End With
End Sub
Coloque a lista dos feriados em R1:R7.
long long title how many chars? lets see 123 ok more? yes 60

We have created lots of YouTube videos just so you can achieve [...]

Another post test yes yes yes or no, maybe ni? :-/

The best flat phpBB theme around. Period. Fine craftmanship and [...]

Do you need a super MOD? Well here it is. chew on this

All you need is right here. Content tag, SEO, listing, Pizza and spaghetti [...]

Lasagna on me this time ok? I got plenty of cash

this should be fantastic. but what about links,images, bbcodes etc etc? [...]

Estamos migrando para uma comunidade no Discord