I have an automation error in excel VBA

Asked

Viewed 76 times

0

My code gives an error and closes Excel for no reason. Follows the photo and the code

inserir a descrição da imagem aqui

 Sub inserir()

Dim tabela As ListObject
Dim n As Integer, id As Integer
Set tabela = Planilha1.ListObjects(1)

tabela.ListRows.Add
id = Range("ID").Value
n = tabela.Range.Rows.Count

tabela.Range(n, 1).Value = id
tabela.Range(n, 2).Value = UserForm1.Txt_codigo.Value
tabela.Range(n, 3).Value = UserForm1.Txt_fabricante.Value
tabela.Range(n, 4).Value = UserForm1.Txt_numero.Value
tabela.Range(n, 5).Value = UserForm1.Cbb_tipo.Value
tabela.Range(n, 6).Value = UserForm1.Txt_opcionais.Value

tabela.ListRows.Add
Range("ID").Value = id + 1
MsgBox "Cadastro efetudo com sucesso!!!", vbInformation, "RRG"

End Sub


Sub editar()


End Sub


Sub Atualizar_listbox()

Dim n As Integer, id As Integer
Set tabela = Planilha1.ListObjects(1)

UserForm1.LB1.RowSource = tabela.Range.Address

End Sub
  • 1

    My dear, format right. On the question-making page there are detailed instructions on formatting. The readability of your code is compromised, with various instructions on the same line.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.