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
#31690
BOM DIA PESSOAL

Galera no cód. abaixo faço um cálculo, cujo resultado deve ser exibido como porcentagem:
Código: Selecionar todos
sv1 = CDbl(.Cells(lngUltLinDados + 1, 6).Value2) + CDbl(.Cells(lngUltLinDados + 1, 7).Value2)
        sv2 = CDbl(.Cells(lngUltLinDados + 1, 4).Value2) + CDbl(.Cells(lngUltLinDados + 1, 5).Value2)
        resultado = (sv1 - sv2) / .Cells(lngUltLinDados + 1, 7).Value2
em seguida trato a formatação dessa resultado com:
Código: Selecionar todos
If resultado = 0# Then
            .Cells(lngUltLinDados + 1, 8).Value = Format(VBA.Round((resultado) * 1000, 2), "0.00") & "%"
        Else
            .Cells(lngUltLinDados + 1, 8).Value = Format(VBA.Round((resultado) * 100, 2), "0.00") & "%"
        End If
na coluna K da sheets ("dados") dependendo do valor do "resultado" se < que 80% é atribuído status "ok"quando não "CMV <20%"
Código: Selecionar todos
If resultado <= 80 Then
            'ONDE TEM 80 ERA PRA SER 80%, PORÉM NÃO ESTOU CONSEGUINDO DETERMINAR O PARÂMETRO DE COMPARAÇÃO, POR SER PORCENTAGEM
            .Cells(lngUltLinDados + 1, 9).Value = "OK"
        Else
            .Cells(lngUltLinDados + 1, 9).Value = "CMV<20%"
        End If
    
        txt_resultado.Value = .Cells(lngUltLinDados + 1, 8).Value
        
        MsgBox ("Resultado MVA% = " & .Cells(lngUltLinDados + 1, 8).Value & " , STATUS: " & .Cells(lngUltLinDados + 1, 9).Value & "")

'ONDE TEM 80 ERA PRA SER 80%, PORÉM NÃO ESTOU CONSEGUINDO DETERMINAR O PARÂMETRO DE COMPARAÇÃO, POR SER PORCENTAGEM, LOGO MEU STATUS NÃO ESTA SENDO ATRIBUÍDO.

Muito obrigado
Em anexo a planilha , o código esta no btn_calcular do frm_estoque!
Você não está autorizado a ver ou baixar esse anexo.
#31694
Tente trocar 80 por 0.8, pois 0.8 equivale a 80%.
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