Estou tentar fazer uma um sisteminha de cadastro no excel usando VBA, mas está dando erro e eu não faço ideia de como consertar o erro. Talvez não seja aqui que eu deveria pedir ajuda mas não tinha ideia de em qual outro lugar poderia pedir.
Sub Cadastrar()
Dim tabela As ListObject
Dim L As Integer, id As Integer
Dim linha As Integer, ValForm As Integer
Dim ValTabela As Integer
Set tabela = Planilha1.ListObjects(1)
L = tabela.Range.Rows.Count
linha = 1
ValForm = UserForm1.txtId.Value
ValTabela = tabela.Range(linha, 1).Value *******
Do Until Cells(linha, coluna) = L
If tabela.Range(linha, 1).Value = ValForm Then
MsgBox "Id já cadastrado, digite outro."
Else
linha = linha + 1
End If
Loop
tabela.Range(L, 1).Value = UserForm1.txtId.Value
tabela.Range(L, 2).Value = UserForm1.txtNome.Value
tabela.Range(L, 3).Value = UserForm1.txtNasc.Value
tabela.Range(L, 4).Value = UserForm1.txtPeso.Value
tabela.Range(L, 5).Value = UserForm1.txtAltura.Value
tabela.Range(L, 6).Value = UserForm1.txtComorb.Value
tabela.Range(L, 7).Value = UserForm1.txtAlerg.Value
tabela.ListRows.Add
Call Limpar
MsgBox "Cadastro realizado.", vbInformation
End Sub
No ponto com asterisco ele está me retornando com esse erro