Notifications
Clear all

VBA controle de frota automotiva

3 Posts
2 Usuários
0 Reactions
986 Visualizações
(@marcoseb51)
Posts: 1
New Member
Topic starter
 

Bom dia,
Estou com um problema na planilha onde tenho que controlar a frota da empresa.
Tenho que calcular a média dos KMs rodados, valor médio gasto em R$ e valor médio abastecido por cada veículo.
Consegui montar alguma coisa, já estou conseguindo o filtro, pesquisa por placa de cada veículo, falta o cálculo da média, estou tentando colocar na frente de cada placa na linha marcada em amarelo, o que acho complicado, ou nas ultimas colunas da direita, alguém poderia me ajudar?
abaixo esta o código que fiz até o momento:

Sub sbx_separar_classificar_somar()
Dim tSoma As Double
Plan2.[1].Delete
Plan3.Range("A1").CurrentRegion.Copy [a1]
Range("C1").CurrentRegion.Sort Key1:=Range("D2"), Order1:=xlAscending, Header:=xlGuess
i = 2
Do While Cells(i, "D") <> ""
sbcateg = Cells(i, "D")
Rows(i).Insert
Cells(i, "D") = sbcateg
Cells(i, "a").Resize(, 18).Interior.ColorIndex = 6
Cells(i, "a").Resize(, 18).Merge
Cells(i, "a").Font.Bold = True
Cells(i, "a").Resize(, 18).HorizontalAlignment = xlCenter
' Range("A" & CStr(i)).HorizontalAlignment = xlCenter
i = i + 1

'CALCULA MÉDIA DE KILOMETROS, COLUNA I
Do While Cells(i, "D") = sbcateg
tSoma = tSoma + Cells(i, "I").Value
i = i + 1
Loop
Cells(i - 1, "S").Value = tSoma
tSoma = 0

'CALCULA MÉDIA DE LITROS, COLUNA M
Do While Cells(i, "D") = sbcateg
RSoma = RSoma + Cells(i, "M").Value
i = i + 1
Loop
Cells(i - 1, "T").Value = RSoma
RSoma = 0

'CALCULA MÉDIA DE GASTO EM REAIS, COLUNA P
Do While Cells(i, "D") = sbcateg
RSoma = RSoma + Cells(i, "P").Value
i = i + 1
Loop
Cells(i - 1, "U").Value = RSoma
RSoma = 0

Loop
End Sub
Sub sbx_limpar_teste()
Plan2.[1].Delete
msgbox ("Dados foram deletados com sucesso!"), vbInformation, "CONTROLE DE FROTA"
End Sub
Sub sbx_mensagem()
msgbox ("Por favor clique na vassourinha, rs....."), vbCritical, "CONTROLE DE FROTA"
End Sub

 
Postado : 03/02/2014 5:22 am
(@fernandofernandes)
Posts: 43750
Illustrious Member
 

..."!"... confira no topico viewtopic.php?f=21&t=3578
consta na biblioteca

 
Postado : 13/02/2014 2:27 pm
(@fernandofernandes)
Posts: 43750
Illustrious Member
 

Zipe e poste a plan que rapidinho vc resolve.

Abs

 
Postado : 13/02/2014 8:34 pm