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
Avatar do usuário
Por Celsosilverio
Posts Avatar
#20005
Bom dia pessoal!
Tenho o seguinte código abaixo:

Sub Consolidar()
Sheets(1).Range("A2:S1000").Clear
plans = Sheets.Count
linha = 2

For n = 2 To plans
lin = 7
Do Until Sheets(n).Cells(lin, 1) = 0

Sheets(1).Cells(linha, 1) = Sheets(n).Cells(lin, 1)
Sheets(1).Cells(linha, 2) = Sheets(n).Cells(lin, 2)
Sheets(1).Cells(linha, 3) = Sheets(n).Cells(lin, 3)

Sheets(1).Cells(linha, 19).Font.ColorIndex = n + 1
Sheets(1).Cells(linha, 19) = Sheets(n).Name

lin = lin + 1
linha = linha + 1

Loop
Next
End Sub

Na Linha 1 preciso que sai formatado na célula como número de porcentagem com duas casas após a vírgula. Ex: 2,50%
Na linha 2 preciso que sai formatado como data. Ex: 10/02/2017
Na linha 3 preciso que sai formatado como número Ex: 1.236,52.

Agradeço desde já,
Avatar do usuário
Por Celsosilverio
Posts Avatar
#20011
Consegui resolver da maneira abaixo:

Sub Consolidar()
Sheets(1).Range("A2:S1000").Clear
plans = Sheets.Count
linha = 2

For n = 2 To plans
lin = 7
Do Until Sheets(n).Cells(lin, 1) = 0

Sheets(1).Cells(linha, 1) = Sheets(n).Cells(lin, 1)
Sheets(1).Cells(linha, 1).NUMBERFORMAT="0.00%"

Sheets(1).Cells(linha, 2) = Sheets(n).Cells(lin, 2)
Sheets(1).Cells(linha, 2).NUMBERFORMAT="DD/MM/YYYY"

Sheets(1).Cells(linha, 3) = Sheets(n).Cells(lin, 3)
Sheets(1).Cells(linha, 3).NUMBERFORMAT="0.00"

Sheets(1).Cells(linha, 19).Font.ColorIndex = n + 1
Sheets(1).Cells(linha, 19) = Sheets(n).Name

lin = lin + 1
linha = linha + 1

Loop
Next
End Sub
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