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
#66834
Trata-se de um formulário simples, porém muito extenso. O erro está aparecendo na linha" Sheets("Lançamentos").Cells(Linha, 316).Value = hora_inicio20.Value". Quando tento cadastrar os dados, ele apresenta esse erro, ainda que o form abra normalmente. Segue fragmento do código e planilha em anexo (a linha que está em negrito é onde está apresentando o erro):

Private Sub CommandButton14_Click()
Call proc1
Call proc2
Call proc3
Call proc4
Call proc5
End Sub

Private Sub proc1()

Linha = Sheets("Lançamentos").Range("A1048576").End(xlUp).Row + 1
Sheets("Lançamentos").Cells(Linha, 1).Value = caixadata.Value
Sheets("Lançamentos").Cells(Linha, 2).Value = caixacodigo.Value
Sheets("Lançamentos").Cells(Linha, 3).Value = hora_inicio.Value
Sheets("Lançamentos").Cells(Linha, 4).Value = hora_fim.Value
Sheets("Lançamentos").Cells(Linha, 5).Value = executante.Value

If botaoveri1 = True Then
Sheets("Lançamentos").Cells(Linha, 6).Value = "X"
End If
If botaoajuste1 = True Then
Sheets("Lançamentos").Cells(Linha, 7).Value = "X"
End If
If botaotroca1 = True Then
Sheets("Lançamentos").Cells(Linha, 8).Value = "X"
End If
If botaolubri1 = True Then
Sheets("Lançamentos").Cells(Linha, 9).Value = "X"
End If
Sheets("Lançamentos").Cells(Linha, 10).Value = hora_inicio2.Value
Sheets("Lançamentos").Cells(Linha, 11).Value = hora_fim2.Value
Sheets("Lançamentos").Cells(Linha, 12).Value = executante2.Value
If botaoveri2 = True Then

...

End sub

(O código se repete por mais várias linhas, mudando apenas as colunas e o índice de hora_inicio, hora_fim e executante)

...

Private Sub proc2()

...

If botaoveri65 = True Then
Sheets("Lançamentos").Cells(Linha, 312).Value = "X"
End If

If botaoajuste65 = True Then
Sheets("Lançamentos").Cells(Linha, 313).Value = "X"
End If

If botaotroca65 = True Then
Sheets("Lançamentos").Cells(Linha, 314).Value = "X"
End If

If botaolubri65 = True Then
Sheets("Lançamentos").Cells(Linha, 315).Value = "X"
End If

Sheets("Lançamentos").Cells(Linha, 316).Value = hora_inicio20.Value
Sheets("Lançamentos").Cells(Linha, 317).Value = hora_fim20.Value
Sheets("Lançamentos").Cells(Linha, 318).Value = executante20.Value
...

Sheets("Lançamentos").Cells(Linha, 894).Value = observacao.Value
MsgBox ("Cadastrado com sucesso!"), vbInformation, "CADASTRO"

End sub

...
Você não está autorizado a ver ou baixar esse anexo.
#66869
Boa noite!
Segue ajustada.
A variável Linha não tinha sido declarada e como ela é utilizada em todas as procs tem que ser uma variável global, então criei ela dentro de um dos módulos, o erro não apresentou mais, mas não testei preenchendo tudo e vendo se realmente está salvando.
Você não está autorizado a ver ou baixar esse anexo.
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