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
Avatar do usuário
Por k4n3d4
Avatar
#680
Boa tarde amigos,

Bem, meu problema é o seguinte,

Tenho aqui um arquivo que contém diversas macros, porém uma delas não está funcionando mais de primeira, ou seja, só funciona se antes de executa-la eu executar outra macro antes.

bem, a macro em questão é simples, é só para chamar um formulário:
Código: Selecionar todos
[code]Sub INPUT_PREMISSAS()
'Abre formulário para input das premissas-chave
   
    PremissasChave.Show
    
End Sub
[/code]

No formulário existem 2 macros, são estas duas:
Código: Selecionar todos
Private Sub UserForm_Activate()
    
    Application.ScreenUpdating = False
    
    Sheets("1. DASHBOARD").Visible = True
    Sheets("1. DASHBOARD").Select
    Calculate
    Sheets("HOME").Select
    
    'INVESTIMENTO
    
    If Range("ValidCapex").Value = "ok" Then
        Me.Label601.Visible = True
    Else
        Me.Label601.Visible = False
    End If
    
    
    Me.TextBox123.Value = Range("CAPEX1IN").Value
    Me.ComboBox101.Value = Range("CAPEX1INDATA").Value
    Me.ComboBox101.Value = Format(ComboBox101.Value, "mmm/yyyy")
    If Range("CAPEX2IN").Value <> "" Then
        Me.CheckBox50 = True
        Me.TextBox124.Value = Range("CAPEX2IN").Value
        Me.ComboBox102.Value = Range("CAPEX2INDATA").Value
        Me.ComboBox102.Value = Format(ComboBox102.Value, "mmm/yyyy")
        If Range("CAPEX3IN").Value <> "" Then
            Me.CheckBox51 = True
            Me.TextBox125.Value = Range("CAPEX3IN").Value
            Me.ComboBox103.Value = Range("CAPEX3INDATA").Value
            Me.ComboBox103.Value = Format(ComboBox103.Value, "mmm/yyyy")
        End If
    End If
    
    Me.TextBox128.Value = Range("CAPEX1TR").Value
    Me.ComboBox106.Value = Range("CAPEX1TRDATA").Value
    Me.ComboBox106.Value = Format(ComboBox106.Value, "mmm/yyyy")
    If Range("CAPEX2TR").Value <> "" Then
        Me.CheckBox54 = True
        Me.TextBox129.Value = Range("CAPEX2TR").Value
        Me.ComboBox107.Value = Range("CAPEX2TRDATA").Value
        Me.ComboBox107.Value = Format(ComboBox107.Value, "mmm/yyyy")
        If Range("CAPEX3TR").Value <> "" Then
            Me.CheckBox55 = True
            Me.TextBox130.Value = Range("CAPEX3TR").Value
            Me.ComboBox108.Value = Range("CAPEX3TRDATA").Value
            Me.ComboBox108.Value = Format(ComboBox108.Value, "mmm/yyyy")
        End If
    End If
    
    Me.TextBox385.Value = Range("CAPEX1CC").Value
    Me.ComboBox197.Value = Range("CAPEX1CCDATA").Value
    Me.ComboBox197.Value = Format(ComboBox197.Value, "mmm/yyyy")
    If Range("CAPEX2TR").Value <> "" Then
        Me.CheckBox85 = True
        Me.TextBox386.Value = Range("CAPEX2CC").Value
        Me.ComboBox198.Value = Range("CAPEX2CCDATA").Value
        Me.ComboBox198.Value = Format(ComboBox198.Value, "mmm/yyyy")
        If Range("CAPEX3CC").Value <> "" Then
            Me.CheckBox86 = True
            Me.TextBox387.Value = Range("CAPEX3CC").Value
            Me.ComboBox199.Value = Range("CAPEX3CCDATA").Value
            Me.ComboBox199.Value = Format(ComboBox199.Value, "mmm/yyyy")
        End If
    End If
    
    Me.TextBox389.Value = Range("CAPEX1IU").Value
    Me.ComboBox201.Value = Range("CAPEX1IUDATA").Value
    Me.ComboBox201.Value = Format(ComboBox201.Value, "mmm/yyyy")
    If Range("CAPEX2IU").Value <> "" Then
        Me.CheckBox88 = True
        Me.TextBox390.Value = Range("CAPEX2IU").Value
        Me.ComboBox202.Value = Range("CAPEX2IUDATA").Value
        Me.ComboBox202.Value = Format(ComboBox202.Value, "mmm/yyyy")
        If Range("CAPEX3IU").Value <> "" Then
            Me.CheckBox89 = True
            Me.TextBox391.Value = Range("CAPEX3IU").Value
            Me.ComboBox203.Value = Range("CAPEX3IUDATA").Value
            Me.ComboBox203.Value = Format(ComboBox203.Value, "mmm/yyyy")
        End If
    End If
    
    Me.TextBox393.Value = Range("CAPEX1SP").Value
    Me.ComboBox205.Value = Range("CAPEX1SPDATA").Value
    Me.ComboBox205.Value = Format(ComboBox205.Value, "mmm/yyyy")
    If Range("CAPEX2SP").Value <> "" Then
        Me.CheckBox91 = True
        Me.TextBox394.Value = Range("CAPEX2SP").Value
        Me.ComboBox206.Value = Range("CAPEX2SPDATA").Value
        Me.ComboBox206.Value = Format(ComboBox206.Value, "mmm/yyyy")
        If Range("CAPEX3SP").Value <> "" Then
            Me.CheckBox92 = True
            Me.TextBox395.Value = Range("CAPEX3SP").Value
            Me.ComboBox207.Value = Range("CAPEX3SPDATA").Value
            Me.ComboBox207.Value = Format(ComboBox207.Value, "mmm/yyyy")
        End If
    End If
    
    Me.TextBox470.Value = Range("CAPEX1EQ").Value
    Me.ComboBox222.Value = Range("CAPEX1EQDATA").Value
    Me.ComboBox222.Value = Format(ComboBox222.Value, "mmm/yyyy")
    If Range("CAPEX2EQ").Value <> "" Then
        Me.CheckBox104 = True
        Me.TextBox471.Value = Range("CAPEX2EQ").Value
        Me.ComboBox223.Value = Range("CAPEX2EQDATA").Value
        Me.ComboBox223.Value = Format(ComboBox223.Value, "mmm/yyyy")
        If Range("CAPEX3EQ").Value <> "" Then
            Me.CheckBox105 = True
            Me.TextBox472.Value = Range("CAPEX3EQ").Value
            Me.ComboBox224.Value = Range("CAPEX3EQDATA").Value
            Me.ComboBox224.Value = Format(ComboBox224.Value, "mmm/yyyy")
        End If
    End If
    
    Me.TextBox473.Value = Range("CAPEX1MA").Value
    Me.ComboBox225.Value = Range("CAPEX1MADATA").Value
    Me.ComboBox225.Value = Format(ComboBox225.Value, "mmm/yyyy")
    If Range("CAPEX2MA").Value <> "" Then
        Me.CheckBox106 = True
        Me.TextBox474.Value = Range("CAPEX2MA").Value
        Me.ComboBox226.Value = Range("CAPEX2MADATA").Value
        Me.ComboBox226.Value = Format(ComboBox226.Value, "mmm/yyyy")
        If Range("CAPEX3MA").Value <> "" Then
            Me.CheckBox107 = True
            Me.TextBox475.Value = Range("CAPEX3MA").Value
            Me.ComboBox227.Value = Range("CAPEX3MADATA").Value
            Me.ComboBox227.Value = Format(ComboBox227.Value, "mmm/yyyy")
        End If
    End If
    
    Me.TextBox476.Value = Range("CAPEX1MEC").Value
    Me.ComboBox228.Value = Range("CAPEX1MECDATA").Value
    Me.ComboBox228.Value = Format(ComboBox228.Value, "mmm/yyyy")
    If Range("CAPEX2MEC").Value <> "" Then
        Me.CheckBox108 = True
        Me.TextBox477.Value = Range("CAPEX2MEC").Value
        Me.ComboBox229.Value = Range("CAPEX2MECDATA").Value
        Me.ComboBox229.Value = Format(ComboBox229.Value, "mmm/yyyy")
        If Range("CAPEX3MEC").Value <> "" Then
            Me.CheckBox109 = True
            Me.TextBox478.Value = Range("CAPEX3MEC").Value
            Me.ComboBox230.Value = Range("CAPEX3MECDATA").Value
            Me.ComboBox230.Value = Format(ComboBox230.Value, "mmm/yyyy")
        End If
    End If
        
    Me.TextBox401.Value = Range("CAPEX1MF").Value
    Me.ComboBox213.Value = Range("CAPEX1MFDATA").Value
    Me.ComboBox213.Value = Format(ComboBox213.Value, "mmm/yyyy")
    If Range("CAPEX2MF").Value <> "" Then
        Me.CheckBox97 = True
        Me.TextBox402.Value = Range("CAPEX2MF").Value
        Me.ComboBox214.Value = Range("CAPEX2MFDATA").Value
        Me.ComboBox214.Value = Format(ComboBox214.Value, "mmm/yyyy")
        If Range("CAPEX3MF").Value <> "" Then
            Me.CheckBox98 = True
            Me.TextBox403.Value = Range("CAPEX3MF").Value
            Me.ComboBox215.Value = Range("CAPEX3MFDATA").Value
            Me.ComboBox215.Value = Format(ComboBox215.Value, "mmm/yyyy")
        End If
    End If
    
    Me.TextBox404.Value = Range("CAPEX1EV").Value
    Me.ComboBox216.Value = Range("CAPEX1EVDATA").Value
    Me.ComboBox216.Value = Format(ComboBox216.Value, "mmm/yyyy")
    If Range("CAPEX2EV").Value <> "" Then
        Me.CheckBox99 = True
        Me.TextBox405.Value = Range("CAPEX2EV").Value
        Me.ComboBox217.Value = Range("CAPEX2EVDATA").Value
        Me.ComboBox217.Value = Format(ComboBox217.Value, "mmm/yyyy")
        If Range("CAPEX3EV").Value <> "" Then
            Me.CheckBox100 = True
            Me.TextBox406.Value = Range("CAPEX3EV").Value
            Me.ComboBox218.Value = Range("CAPEX3EVDATA").Value
            Me.ComboBox218.Value = Format(ComboBox218.Value, "mmm/yyyy")
        End If
    End If
     

End Sub
Código: Selecionar todos
Private Sub UserForm_Initialize()
'Nome do frame
    
    Application.ScreenUpdating = False
    
    With Me.Frame1
        .ScrollBars = fmScrollBarsVertical
        'Mudar X.X para atender as necessidades
        .ScrollHeight = .InsideHeight * 2.5
        .ScrollWidth = .InsideWidth * 9
    End With
    
    With Me.Frame2
        .ScrollBars = fmScrollBarsVertical
        'Mudar X.X para atender as necessidades
        .ScrollHeight = .InsideHeight * 2.5
        .ScrollWidth = .InsideWidth * 9
    End With
    
    With Me.Frame3
        .ScrollBars = fmScrollBarsVertical
        'Mudar X.X para atender as necessidades
        .ScrollHeight = .InsideHeight * 2.5
        .ScrollWidth = .InsideWidth * 9
    End With
    
    With Me.Frame4
        .ScrollBars = fmScrollBarsVertical
        'Mudar X.X para atender as necessidades
        .ScrollHeight = .InsideHeight * 2.5
        .ScrollWidth = .InsideWidth * 9
    End With
    
    With Me.Frame5
        .ScrollBars = fmScrollBarsVertical
        'Mudar X.X para atender as necessidades
        .ScrollHeight = .InsideHeight * 2.5
        .ScrollWidth = .InsideWidth * 9
    End With
    
      With Me.Frame6
        .ScrollBars = fmScrollBarsVertical
        'Mudar X.X para atender as necessidades
        .ScrollHeight = .InsideHeight * 2.5
        .ScrollWidth = .InsideWidth * 9
    End With

    'PREMISSAS GERAIS
    
    Me.TextBox1.Value = Range("NomeProjeto").Value
    
    Me.TextBox2.Value = Range("InicioProjeto").Value
    TextBox2.Value = Format(TextBox2.Value, "mmm/yyyy")
    
    Me.TextBox3.Value = Range("DurImpl").Value
    
    Me.TextBox5.Value = Range("DurOper").Value
    
    Me.TextBox9.Value = Range("hs_dia").Value
    
    Me.TextBox10.Value = Range("CH4noBiogas").Value * 100
    
    Me.TextBox202.Value = Range("CH4noBiometano").Value * 100
    
    Me.TextBox11.Value = Range("PerdProcProd").Value * 100
    
    Me.TextBox13.Value = Range("PcsProj").Value
    
    Me.TextBox14.Value = Range("PcsRef").Value
    
    Me.TextBox201.Value = Range("PartProj").Value * 100
    
    Me.TextBox469.Value = Range("DIVIDENDO").Value * 100
    
    Me.ComboBox221.Value = Range("MDIVIDENDO").Value
    
    Me.ComboBox164.Value = Range("estado").Value
        
    Me.ComboBox158.Value = Range("Ocio1DE").Value
    Me.ComboBox158.Value = Format(ComboBox158.Value, "mmm/yyyy")
    
    Me.ComboBox159.Value = Range("Ocio1ATE").Value
    Me.ComboBox159.Value = Format(ComboBox159.Value, "mmm/yyyy")
    
    Me.TextBox203.Value = Range("Ocio1").Value * 100
    
    If Range("Ocio2DE").Value <> "" Then
        Me.CheckBox73.Value = True
        
        Me.ComboBox160.Value = Range("Ocio2DE").Value
        Me.ComboBox160.Value = Format(ComboBox160.Value, "mmm/yyyy")
    
        Me.ComboBox161.Value = Range("Ocio2ATE").Value
        Me.ComboBox161.Value = Format(ComboBox161.Value, "mmm/yyyy")
    
        Me.TextBox204.Value = Range("Ocio2").Value * 100
        
        If Range("Ocio3DE").Value <> "" Then
            Me.CheckBox74.Value = True
        
            Me.TextBox205.Value = Range("Ocio3").Value * 100
        End If
    End If
    
    Me.ComboBox166.Value = Range("CapMax1DE").Value
    Me.ComboBox166.Value = Format(ComboBox166.Value, "mmm/yyyy")
    
    Me.ComboBox167.Value = Range("CapMax1ATE").Value
    Me.ComboBox167.Value = Format(ComboBox167.Value, "mmm/yyyy")
    
    Me.TextBox210.Value = Range("CapMax1").Value
    
    If Range("Ocio2DE").Value <> "" Then
        Me.CheckBox75.Value = True
        
        Me.ComboBox168.Value = Range("CapMax2DE").Value
        Me.ComboBox168.Value = Format(ComboBox168.Value, "mmm/yyyy")
    
        Me.ComboBox169.Value = Range("CapMax2ATE").Value
        Me.ComboBox169.Value = Format(ComboBox169.Value, "mmm/yyyy")
    
        Me.TextBox211.Value = Range("CapMax2").Value
        
        If Range("CapMax3DE").Value <> "" Then
            Me.CheckBox76.Value = True
        
            Me.TextBox212.Value = Range("CapMax3").Value
        End If
    End If
    
    'RECEITAS
    
    If Range("tipoVB").Value = 1 Then
        Me.OptionButton11 = True
        Me.TextBox16.Value = Range("m1VB").Value
        Me.TextBox17.Value = Range("m2VB").Value
        Me.TextBox18.Value = Range("m3VB").Value
        Me.TextBox19.Value = Range("m4VB").Value
        Me.TextBox20.Value = Range("m5VB").Value
        Me.TextBox21.Value = Range("m6VB").Value
        Me.TextBox22.Value = Range("m7VB").Value
        Me.TextBox23.Value = Range("m8VB").Value
        Me.TextBox24.Value = Range("m9VB").Value
        Me.TextBox25.Value = Range("m10VB").Value
        Me.TextBox26.Value = Range("m11VB").Value
        Me.TextBox27.Value = Range("m12VB").Value
        Me.TextBox28.Value = Range("m13VB").Value
        Me.TextBox29.Value = Range("m14VB").Value
        Me.TextBox30.Value = Range("m15VB").Value
        Me.TextBox31.Value = Range("m16VB").Value
        Me.TextBox32.Value = Range("m17VB").Value
        Me.TextBox33.Value = Range("m18VB").Value
        Me.TextBox34.Value = Range("m19VB").Value
        Me.TextBox35.Value = Range("m20VB").Value
        Me.TextBox36.Value = Range("m21VB").Value
        Me.TextBox37.Value = Range("m22VB").Value
        Me.TextBox38.Value = Range("m23VB").Value
        Me.TextBox39.Value = Range("m24VB").Value
        If Range("tipo24maisVB").Value = 1 Then Me.OptionButton1.Value = True
        If Range("tipo24maisVB").Value = 2 Then Me.OptionButton2.Value = True
        If Range("tipo24maisVB").Value = 3 Then
            Me.OptionButton3.Value = True
            Me.TextBox298.Value = Range("ANO3VB").Value
            Me.TextBox299.Value = Range("ANO4VB").Value
            Me.TextBox300.Value = Range("ANO5VB").Value
            Me.TextBox301.Value = Range("ANO6VB").Value
            Me.TextBox302.Value = Range("ANO7VB").Value
            Me.TextBox303.Value = Range("ANO8VB").Value
            Me.TextBox304.Value = Range("ANO9VB").Value
            Me.TextBox305.Value = Range("ANO10VB").Value
            Me.TextBox306.Value = Range("ANO11VB").Value
            Me.TextBox307.Value = Range("ANO12VB").Value
            Me.TextBox308.Value = Range("ANO13VB").Value
            Me.TextBox309.Value = Range("ANO14VB").Value
            Me.TextBox310.Value = Range("ANO15VB").Value
            Me.TextBox311.Value = Range("ANO16VB").Value
            Me.TextBox312.Value = Range("ANO17VB").Value
            Me.TextBox313.Value = Range("ANO18VB").Value
            Me.TextBox314.Value = Range("ANO19VB").Value
            Me.TextBox315.Value = Range("ANO20VB").Value
        End If
    Else
        Me.OptionButton12 = True
        Me.TextBox296.Value = Range("ANO1VB").Value
        Me.TextBox297.Value = Range("ANO2VB").Value
        Me.TextBox298.Value = Range("ANO3VB").Value
        Me.TextBox299.Value = Range("ANO4VB").Value
        Me.TextBox300.Value = Range("ANO5VB").Value
        Me.TextBox301.Value = Range("ANO6VB").Value
        Me.TextBox302.Value = Range("ANO7VB").Value
        Me.TextBox303.Value = Range("ANO8VB").Value
        Me.TextBox304.Value = Range("ANO9VB").Value
        Me.TextBox305.Value = Range("ANO10VB").Value
        Me.TextBox306.Value = Range("ANO11VB").Value
        Me.TextBox307.Value = Range("ANO12VB").Value
        Me.TextBox308.Value = Range("ANO13VB").Value
        Me.TextBox309.Value = Range("ANO14VB").Value
        Me.TextBox310.Value = Range("ANO15VB").Value
        Me.TextBox311.Value = Range("ANO16VB").Value
        Me.TextBox312.Value = Range("ANO17VB").Value
        Me.TextBox313.Value = Range("ANO18VB").Value
        Me.TextBox314.Value = Range("ANO19VB").Value
        Me.TextBox315.Value = Range("ANO20VB").Value
    End If
       
    Me.TextBox40.Value = Range("PVsemImp").Value
    
    Me.ComboBox172.Value = Range("DPVsemImp").Value
    Me.ComboBox172.Value = Format(ComboBox172.Value, "mmm/yyyy")
    
    If Range("PVsemImp2").Value <> "" Then
        Me.CheckBox72 = True
        Me.TextBox200.Value = Range("PVsemImp2").Value
        Me.ComboBox156.Value = Range("DPVsemImp2").Value
        Me.ComboBox156.Value = Format(ComboBox156.Value, "mmm/yyyy")
    End If
    
    Me.TextBox208.Value = Range("ICMS").Value * 100
    Me.TextBox209.Value = Range("ISS").Value * 100
    
    Me.ComboBox17.Value = Range("IndexRec").Value
    Me.ComboBox18.Value = Range("MesUpdateRec").Value
    
    'CUSTOS E DESPESAS
    
    Me.TextBox75.Value = Range("P0MOD").Value
    
    If Range("P1MOD").Value <> "" Then
        Me.CheckBox9.Value = True
        Me.ComboBox25.Value = Range("P1MODDE").Value
        Me.ComboBox26.Value = Range("P1MODATE").Value
        Me.TextBox76.Value = Range("P1MOD").Value
        If Range("P2MOD").Value <> "" Then
            Me.CheckBox10.Value = True
            Me.TextBox77.Value = Range("P2MOD").Value
        End If
    End If
    
    Me.TextBox316.Value = Range("RTMODC").Value * 100
    Me.TextBox317.Value = Range("RTMODD").Value * 100
    
    Me.TextBox318.Value = Range("P0MANCAP").Value
    
    If Range("P1MANCAP").Value <> "" Then
        Me.CheckBox79.Value = True
        Me.ComboBox182.Value = Range("P1MANCAPDE").Value
        Me.ComboBox183.Value = Range("P1MANCAPATE").Value
        Me.TextBox319.Value = Range("P1MANCAP").Value
        If Range("P2MANCAP").Value <> "" Then
            Me.CheckBox80.Value = True
            Me.TextBox320.Value = Range("P2MANCAP").Value
        End If
    End If
    
    Me.TextBox323.Value = Range("P0MANPUR").Value
    
    If Range("P1MANPUR").Value <> "" Then
        Me.CheckBox81.Value = True
        Me.ComboBox186.Value = Range("P1MANPURDE").Value
        Me.ComboBox187.Value = Range("P1MANPURATE").Value
        Me.TextBox324.Value = Range("P1MANPUR").Value
        If Range("P2MANPUR").Value <> "" Then
            Me.CheckBox82.Value = True
            Me.TextBox325.Value = Range("P2MANPUR").Value
        End If
    End If
    
    If Range("PURVAR").Value = 2 Then
        CheckBox101 = True
        TextBox448.Value = Range("PURVAR1").Value
    End If
    
    Me.TextBox326.Value = Range("P0MANDIS").Value
    
    If Range("P1MANDIS").Value <> "" Then
        Me.CheckBox84.Value = True
        Me.ComboBox190.Value = Range("P1MANDISDE").Value
        Me.ComboBox191.Value = Range("P1MANDISATE").Value
        Me.TextBox327.Value = Range("P1MANDIS").Value
        If Range("P2MANDIS").Value <> "" Then
            Me.CheckBox83.Value = True
            Me.TextBox328.Value = Range("P2MANDIS").Value
        End If
    End If
    
    Me.ComboBox61.Value = Range("IndexCustos").Value
    Me.ComboBox62.Value = Range("MesUpdateCustos").Value
    Me.ComboBox220.Value = Range("DACD").Value
    Me.ComboBox220.Value = Format(ComboBox220.Value, "mmm/yyyy")
    
    Me.TextBox425.Value = Range("P0SEGURO").Value * 100
    Me.TextBox434.Value = Range("P1SEGURO").Value * 100
    Me.TextBox451.Value = Range("BCICMSOM").Value * 100
    
    'ENERGIA ELÉTRICA
    
    If Range("MERCADOEE2").Value = 2 Then
        Me.ComboBox196.Value = "Livre"
    Else
        Me.ComboBox196.Value = "Regulado"
    End If
    
    Me.TextBox331.Value = Range("DEMFP").Value
    Me.TextBox332.Value = Range("DEMHP").Value
    Me.TextBox333.Value = Range("CONFP").Value
    Me.TextBox343.Value = Range("CONHP").Value
    Me.TextBox334.Value = Range("CONVAR").Value
    Me.TextBox335.Value = Range("TUSDFP").Value
    Me.TextBox336.Value = Range("TUSDHP").Value
    Me.TextBox337.Value = Range("TUSDeFP").Value
    Me.TextBox338.Value = Range("TUSDeHP").Value
    Me.TextBox339.Value = Range("TEBAFP").Value
    Me.TextBox340.Value = Range("TEBAHP").Value
    Me.TextBox341.Value = Range("LIVRE").Value
    
    Me.TextBox344.Value = Range("FRLIV1").Value * 100
    Me.TextBox346.Value = Range("FRLIV2").Value * 100
    Me.TextBox349.Value = Range("FRLIV3").Value * 100
    Me.TextBox351.Value = Range("FRLIV4").Value * 100
    Me.TextBox353.Value = Range("FRLIV5").Value * 100
    Me.TextBox355.Value = Range("FRLIV6").Value * 100
    Me.TextBox357.Value = Range("FRLIV7").Value * 100
    Me.TextBox359.Value = Range("FRLIV8").Value * 100
    Me.TextBox361.Value = Range("FRLIV9").Value * 100
    Me.TextBox363.Value = Range("FRLIV10").Value * 100
    Me.TextBox365.Value = Range("FRLIV11").Value * 100
    Me.TextBox367.Value = Range("FRLIV12").Value * 100
    Me.TextBox369.Value = Range("FRLIV13").Value * 100
    Me.TextBox371.Value = Range("FRLIV14").Value * 100
    Me.TextBox373.Value = Range("FRLIV15").Value * 100
    Me.TextBox375.Value = Range("FRLIV16").Value * 100
    Me.TextBox377.Value = Range("FRLIV17").Value * 100
    Me.TextBox379.Value = Range("FRLIV18").Value * 100
    Me.TextBox381.Value = Range("FRLIV19").Value * 100
    Me.TextBox383.Value = Range("FRLIV20").Value * 100
    
    Me.TextBox345.Value = Range("FRREG1").Value * 100
    Me.TextBox347.Value = Range("FRREG2").Value * 100
    Me.TextBox348.Value = Range("FRREG3").Value * 100
    Me.TextBox350.Value = Range("FRREG4").Value * 100
    Me.TextBox352.Value = Range("FRREG5").Value * 100
    Me.TextBox354.Value = Range("FRREG6").Value * 100
    Me.TextBox356.Value = Range("FRREG7").Value * 100
    Me.TextBox358.Value = Range("FRREG8").Value * 100
    Me.TextBox360.Value = Range("FRREG9").Value * 100
    Me.TextBox362.Value = Range("FRREG10").Value * 100
    Me.TextBox364.Value = Range("FRREG11").Value * 100
    Me.TextBox366.Value = Range("FRREG12").Value * 100
    Me.TextBox368.Value = Range("FRREG13").Value * 100
    Me.TextBox370.Value = Range("FRREG14").Value * 100
    Me.TextBox372.Value = Range("FRREG15").Value * 100
    Me.TextBox374.Value = Range("FRREG16").Value * 100
    Me.TextBox376.Value = Range("FRREG17").Value * 100
    Me.TextBox378.Value = Range("FRREG18").Value * 100
    Me.TextBox380.Value = Range("FRREG19").Value * 100
    Me.TextBox382.Value = Range("FRREG20").Value * 100
    
    Me.TextBox329.Value = Range("RTEEC").Value * 100
    Me.TextBox330.Value = Range("RTEED").Value * 100
    Me.TextBox384.Value = Range("ICMSEE").Value * 100
    
    'INVESTIMENTO
    
    If Range("ValidCapex").Value = "ok" Then
        Me.Label601.Visible = True
    Else
        Me.Label601.Visible = False
    End If
    
    
    Me.TextBox123.Value = Range("CAPEX1IN").Value
    Me.ComboBox101.Value = Range("CAPEX1INDATA").Value
    Me.ComboBox101.Value = Format(ComboBox101.Value, "mmm/yyyy")
    If Range("CAPEX2IN").Value <> "" Then
        Me.CheckBox50 = True
        Me.TextBox124.Value = Range("CAPEX2IN").Value
        Me.ComboBox102.Value = Range("CAPEX2INDATA").Value
        Me.ComboBox102.Value = Format(ComboBox102.Value, "mmm/yyyy")
        If Range("CAPEX3IN").Value <> "" Then
            Me.CheckBox51 = True
            Me.TextBox125.Value = Range("CAPEX3IN").Value
            Me.ComboBox103.Value = Range("CAPEX3INDATA").Value
            Me.ComboBox103.Value = Format(ComboBox103.Value, "mmm/yyyy")
        End If
    End If
    
    Me.TextBox128.Value = Range("CAPEX1TR").Value
    Me.ComboBox106.Value = Range("CAPEX1TRDATA").Value
    Me.ComboBox106.Value = Format(ComboBox106.Value, "mmm/yyyy")
    If Range("CAPEX2TR").Value <> "" Then
        Me.CheckBox54 = True
        Me.TextBox129.Value = Range("CAPEX2TR").Value
        Me.ComboBox107.Value = Range("CAPEX2TRDATA").Value
        Me.ComboBox107.Value = Format(ComboBox107.Value, "mmm/yyyy")
        If Range("CAPEX3TR").Value <> "" Then
            Me.CheckBox55 = True
            Me.TextBox130.Value = Range("CAPEX3TR").Value
            Me.ComboBox108.Value = Range("CAPEX3TRDATA").Value
            Me.ComboBox108.Value = Format(ComboBox108.Value, "mmm/yyyy")
        End If
    End If
    
    Me.TextBox385.Value = Range("CAPEX1CC").Value
    Me.ComboBox197.Value = Range("CAPEX1CCDATA").Value
    Me.ComboBox197.Value = Format(ComboBox197.Value, "mmm/yyyy")
    If Range("CAPEX2TR").Value <> "" Then
        Me.CheckBox85 = True
        Me.TextBox386.Value = Range("CAPEX2CC").Value
        Me.ComboBox198.Value = Range("CAPEX2CCDATA").Value
        Me.ComboBox198.Value = Format(ComboBox198.Value, "mmm/yyyy")
        If Range("CAPEX3CC").Value <> "" Then
            Me.CheckBox86 = True
            Me.TextBox387.Value = Range("CAPEX3CC").Value
            Me.ComboBox199.Value = Range("CAPEX3CCDATA").Value
            Me.ComboBox199.Value = Format(ComboBox199.Value, "mmm/yyyy")
        End If
    End If
    
    Me.TextBox389.Value = Range("CAPEX1IU").Value
    Me.ComboBox201.Value = Range("CAPEX1IUDATA").Value
    Me.ComboBox201.Value = Format(ComboBox201.Value, "mmm/yyyy")
    If Range("CAPEX2IU").Value <> "" Then
        Me.CheckBox88 = True
        Me.TextBox390.Value = Range("CAPEX2IU").Value
        Me.ComboBox202.Value = Range("CAPEX2IUDATA").Value
        Me.ComboBox202.Value = Format(ComboBox202.Value, "mmm/yyyy")
        If Range("CAPEX3IU").Value <> "" Then
            Me.CheckBox89 = True
            Me.TextBox391.Value = Range("CAPEX3IU").Value
            Me.ComboBox203.Value = Range("CAPEX3IUDATA").Value
            Me.ComboBox203.Value = Format(ComboBox203.Value, "mmm/yyyy")
        End If
    End If
    
    Me.TextBox393.Value = Range("CAPEX1SP").Value
    Me.ComboBox205.Value = Range("CAPEX1SPDATA").Value
    Me.ComboBox205.Value = Format(ComboBox205.Value, "mmm/yyyy")
    If Range("CAPEX2SP").Value <> "" Then
        Me.CheckBox91 = True
        Me.TextBox394.Value = Range("CAPEX2SP").Value
        Me.ComboBox206.Value = Range("CAPEX2SPDATA").Value
        Me.ComboBox206.Value = Format(ComboBox206.Value, "mmm/yyyy")
        If Range("CAPEX3SP").Value <> "" Then
            Me.CheckBox92 = True
            Me.TextBox395.Value = Range("CAPEX3SP").Value
            Me.ComboBox207.Value = Range("CAPEX3SPDATA").Value
            Me.ComboBox207.Value = Format(ComboBox207.Value, "mmm/yyyy")
        End If
    End If
    
    Me.TextBox470.Value = Range("CAPEX1EQ").Value
    Me.ComboBox222.Value = Range("CAPEX1EQDATA").Value
    Me.ComboBox222.Value = Format(ComboBox222.Value, "mmm/yyyy")
    If Range("CAPEX2EQ").Value <> "" Then
        Me.CheckBox104 = True
        Me.TextBox471.Value = Range("CAPEX2EQ").Value
        Me.ComboBox223.Value = Range("CAPEX2EQDATA").Value
        Me.ComboBox223.Value = Format(ComboBox223.Value, "mmm/yyyy")
        If Range("CAPEX3EQ").Value <> "" Then
            Me.CheckBox105 = True
            Me.TextBox472.Value = Range("CAPEX3EQ").Value
            Me.ComboBox224.Value = Range("CAPEX3EQDATA").Value
            Me.ComboBox224.Value = Format(ComboBox224.Value, "mmm/yyyy")
        End If
    End If
    
    Me.TextBox473.Value = Range("CAPEX1MA").Value
    Me.ComboBox225.Value = Range("CAPEX1MADATA").Value
    Me.ComboBox225.Value = Format(ComboBox225.Value, "mmm/yyyy")
    If Range("CAPEX2MA").Value <> "" Then
        Me.CheckBox106 = True
        Me.TextBox474.Value = Range("CAPEX2MA").Value
        Me.ComboBox226.Value = Range("CAPEX2MADATA").Value
        Me.ComboBox226.Value = Format(ComboBox226.Value, "mmm/yyyy")
        If Range("CAPEX3MA").Value <> "" Then
            Me.CheckBox107 = True
            Me.TextBox475.Value = Range("CAPEX3MA").Value
            Me.ComboBox227.Value = Range("CAPEX3MADATA").Value
            Me.ComboBox227.Value = Format(ComboBox227.Value, "mmm/yyyy")
        End If
    End If
    
    Me.TextBox476.Value = Range("CAPEX1MEC").Value
    Me.ComboBox228.Value = Range("CAPEX1MECDATA").Value
    Me.ComboBox228.Value = Format(ComboBox228.Value, "mmm/yyyy")
    If Range("CAPEX2MEC").Value <> "" Then
        Me.CheckBox108 = True
        Me.TextBox477.Value = Range("CAPEX2MEC").Value
        Me.ComboBox229.Value = Range("CAPEX2MECDATA").Value
        Me.ComboBox229.Value = Format(ComboBox229.Value, "mmm/yyyy")
        If Range("CAPEX3MEC").Value <> "" Then
            Me.CheckBox109 = True
            Me.TextBox478.Value = Range("CAPEX3MEC").Value
            Me.ComboBox230.Value = Range("CAPEX3MECDATA").Value
            Me.ComboBox230.Value = Format(ComboBox230.Value, "mmm/yyyy")
        End If
    End If
        
    Me.TextBox401.Value = Range("CAPEX1MF").Value
    Me.ComboBox213.Value = Range("CAPEX1MFDATA").Value
    Me.ComboBox213.Value = Format(ComboBox213.Value, "mmm/yyyy")
    If Range("CAPEX2MF").Value <> "" Then
        Me.CheckBox97 = True
        Me.TextBox402.Value = Range("CAPEX2MF").Value
        Me.ComboBox214.Value = Range("CAPEX2MFDATA").Value
        Me.ComboBox214.Value = Format(ComboBox214.Value, "mmm/yyyy")
        If Range("CAPEX3MF").Value <> "" Then
            Me.CheckBox98 = True
            Me.TextBox403.Value = Range("CAPEX3MF").Value
            Me.ComboBox215.Value = Range("CAPEX3MFDATA").Value
            Me.ComboBox215.Value = Format(ComboBox215.Value, "mmm/yyyy")
        End If
    End If
    
    Me.TextBox404.Value = Range("CAPEX1EV").Value
    Me.ComboBox216.Value = Range("CAPEX1EVDATA").Value
    Me.ComboBox216.Value = Format(ComboBox216.Value, "mmm/yyyy")
    If Range("CAPEX2EV").Value <> "" Then
        Me.CheckBox99 = True
        Me.TextBox405.Value = Range("CAPEX2EV").Value
        Me.ComboBox217.Value = Range("CAPEX2EVDATA").Value
        Me.ComboBox217.Value = Format(ComboBox217.Value, "mmm/yyyy")
        If Range("CAPEX3EV").Value <> "" Then
            Me.CheckBox100 = True
            Me.TextBox406.Value = Range("CAPEX3EV").Value
            Me.ComboBox218.Value = Range("CAPEX3EVDATA").Value
            Me.ComboBox218.Value = Format(ComboBox218.Value, "mmm/yyyy")
        End If
    End If
    
    Me.TextBox407.Value = Range("DEPRECINTP").Value
    Me.TextBox410.Value = Range("DEPRECCCTP").Value
    Me.TextBox411.Value = Range("DEPRECIUTP").Value
    Me.TextBox414.Value = Range("DEPRECSPTP").Value
    Me.TextBox479.Value = Range("DEPRECEQTP").Value
    Me.TextBox480.Value = Range("DEPRECMATP").Value
    Me.TextBox481.Value = Range("DEPRECMECTP").Value
    Me.TextBox416.Value = Range("DEPRECMFTP").Value
    Me.TextBox418.Value = Range("DEPRECEVTP").Value
    Me.TextBox423.Value = Range("RTDEPC").Value * 100
    Me.TextBox424.Value = Range("RTDEPD").Value * 100
    Me.TextBox421.Value = Range("RTMENAC").Value * 100
    Me.TextBox422.Value = Range("RTMEINT").Value * 100
    
    'ENDIVIDAMENTO
    
    If Range("ValidLiber").Value = "ok" Then
        Me.Label600.Visible = True
    Else
        Me.Label600.Visible = False
    End If
    
    Me.TextBox152.Value = Range("DivBPTJ").Value * 100
    Me.TextBox153.Value = Range("DivBPPC").Value
    Me.TextBox459.Value = Range("DivBPPCJ").Value
    Me.TextBox154.Value = Range("DivBPPP").Value
    Me.TextBox438.Value = Range("DivBPG").Value * 100
    Me.TextBox450.Value = Range("DivBPC").Value
    Me.TextBox439.Value = Range("DivBPIF").Value * 100
    
    Me.TextBox441.Value = Range("DivBPRTJ").Value * 100
    Me.TextBox442.Value = Range("DivBPRPC").Value
    Me.TextBox460.Value = Range("DivBPRPCJ").Value
    Me.TextBox443.Value = Range("DivBPRPP").Value
    Me.TextBox444.Value = Range("DivBPRG").Value * 100
    Me.TextBox449.Value = Range("DivBPRC").Value
    Me.TextBox445.Value = Range("DivBPRIF").Value * 100
    
    Me.TextBox462.Value = Range("DivMTJ").Value * 100
    Me.TextBox463.Value = Range("DivMPC").Value
    Me.TextBox468.Value = Range("DivMPCJ").Value
    Me.TextBox464.Value = Range("DivMPP").Value
    Me.TextBox466.Value = Range("DivMIF").Value * 100
    
    'TRIBUTOS
    
    Me.TextBox435.Value = Range("RECPCCAPEX").Value
    Me.TextBox436.Value = Range("RECICCAPEX").Value
    
    Me.ComboBox175.Value = Range("RT1ATE").Value
    Me.ComboBox173.Value = Range("RT1VL").Value
    
    If Range("RT2DE").Value <> "" Then
        Me.CheckBox77.Value = True
        
        Me.ComboBox176.Value = Range("RT2DE").Value
        Me.ComboBox177.Value = Range("RT2ATE").Value
        Me.ComboBox180.Value = Range("RT2VL").Value
    
        If Range("RT3DE").Value <> "" Then
            Me.CheckBox78.Value = True
            Me.ComboBox178.Value = Range("RT3DE").Value
            Me.ComboBox179.Value = Range("RT3ATE").Value
            Me.ComboBox181.Value = Range("RT3VL").Value
        End If
    End If
    
    Me.TextBox446.Value = Range("AIRPRES").Value * 100
    Me.TextBox447.Value = Range("ACSPRES").Value * 100
    
    If Range("INICMSR").Value = "" Then Me.OptionButton18.Value = True
    If Range("INICMSR").Value = 1 Then Me.OptionButton15.Value = True
    If Range("INICMSR").Value = 2 Then Me.OptionButton16.Value = True
    If Range("INICMSR").Value = 3 Then Me.OptionButton17.Value = True
    
    Me.TextBox452.Value = Range("INCENTIVO").Value * 100
    
    If Range("INCBSIR").Value = "SIM" Then
        OptionButton19.Value = True
    Else
        OptionButton20.Value = True
    End If
    
    If Range("PFINANCICMS").Value = "" Then
        Me.TextBox456.Value = ""
    Else
        Me.TextBox456.Value = Range("PFINANCICMS").Value / 12
    End If
    
    If Range("JFINANCICMS").Value = "" Then
        Me.TextBox457.Value = ""
    Else
        Me.TextBox457.Value = Range("JFINANCICMSAA") * 100
    End If
    
    Me.TextBox458.Value = Range("DFINANCICMS").Value * 100
 
    If Range("INFEDR").Value = 1 Then CheckBox102.Value = True
    Me.TextBox453.Value = Range("INCENTIVOIR").Value * 100
        
    If Range("INCICMSCAPEX").Value = 1 Then CheckBox103.Value = True
    Me.TextBox454.Value = Range("ICMSCAPEX").Value * 100
   
    'FINANCEIRA
    
    Me.TextBox276.Value = Range("BioAV").Value * 100
    Me.TextBox277.Value = Range("Bio30CR").Value * 100
    Me.TextBox278.Value = Range("Bio60CR").Value * 100
    Me.TextBox279.Value = Range("Bio90CR").Value * 100
    Me.TextBox280.Value = Range("ResAV").Value * 100
    Me.TextBox281.Value = Range("Res30CR").Value * 100
    Me.TextBox282.Value = Range("Res60CR").Value * 100
    Me.TextBox283.Value = Range("Res90CR").Value * 100
    Me.TextBox284.Value = Range("FerAV").Value * 100
    Me.TextBox285.Value = Range("Fer30CR").Value * 100
    Me.TextBox286.Value = Range("Fer60CR").Value * 100
    Me.TextBox287.Value = Range("Fer90CR").Value * 100
    Me.TextBox288.Value = Range("Out1AV").Value * 100
    Me.TextBox289.Value = Range("Out130CR").Value * 100
    Me.TextBox290.Value = Range("Out160CR").Value * 100
    Me.TextBox291.Value = Range("Out190CR").Value * 100
    Me.TextBox292.Value = Range("Out2AV").Value * 100
    Me.TextBox293.Value = Range("Out230CR").Value * 100
    Me.TextBox294.Value = Range("Out260CR").Value * 100
    Me.TextBox295.Value = Range("Out290CR").Value * 100
    
    If Range("TipoCAPM").Value = 1 Then Me.OptionButton13 = True
    If Range("TipoCAPM").Value = 2 Then Me.OptionButton14 = True
    Me.TextBox427.Value = Range("CAPMfixo").Value * 100
    Me.TextBox428.Value = Range("RF").Value * 100
    Me.TextBox430.Value = Range("cpi").Value * 100
    Me.TextBox431.Value = Range("BetaDesalavanc").Value
    Me.TextBox432.Value = Range("RiscoMerc").Value * 100
    Me.TextBox433.Value = Range("RiscoAdc").Value * 100
    
    
End Sub

Desde já agradeço a ajuda ^^
#681
Boa tarde!!!

Essa macro está sendo executada de que forma em seu projeto?
Por um comando call, ou evento ...?

Seria interessante postar seu arquivo modelo, para saber como está o formulário etc.

Att
Avatar do usuário
Por k4n3d4
Avatar
#740
Desculpe a demora,

Consegui resolver o problema. Descobri que toda vez que salvava antes de executar a macro ela funcionava sem problemas, então eu apenas adicionei uma linha de comando para salvar no inicio da macro. resolveu o problema.

De qualquer forma muito obrigado ^^
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