Ir para conteúdo
Fórum Script Brasil
  • 0

VBA Para cadastro com error de compilação: Método ou membro de dados não encontrado


Yago bezerra

Pergunta

Bom dia. 

Já verifiquei os nomes das teclas do userform com o código porém continuo com esse erro.
diversas vezes postei no ChatGPT e ele corrigiu mas o erro persiste.

 

Sub B_cadastrarauditor_Click()

Dim audit_off As Object
Dim audit_man As Object
Dim a_man As Object
Dim a_off As Object
Dim TXT_auditorname As MSForms.TextBox
Set TXT_auditorname = Me.TXT_auditorname
Dim ws As Worksheet
Dim OB_off As MSForms.OptionButton
Set OB_off = Me.OB_off
Dim OB_man As MSForms.OptionButton
Set OB_man = Me.OB_man
Dim nextRow As Long

    If OB_off = False And OB_man = False Then
        MsgBox "Selecione em qual área será cadastrado o auditor"
        Exit Sub
    ElseIf TXT_auditorname = "" Then
        MsgBox "Preencha o nome do auditor"
    End If

    
    If OB_off = True Then
        Set ws = ThisWorkbook.Sheets("Database_tables")
    
        'Get the next empty row in the table
        nextRow = ws.ListObjects("audit_off").Range.Rows.Count + 1
    
        'Capture data from the UserForm text box
        ws.ListObjects("audit_off").ListRows.Add.Range(1, 1).Value = TXT_auditorname.Value
    
        'Clear the UserForm text box after data is captured
        TXT_auditorname.Value = ""
        
        MsgBox "Auditor cadastrado com sucesso"
        
    ElseIf OB_man = True Then
        Set ws = ThisWorkbook.Sheets("Database_tables")
    
        'Get the next empty row in the table
        nextRow = ws.ListObjects("audit_man").Range.Rows.Count + 1
    
        'Capture data from the UserForm text box
        ws.ListObjects("audit_man").ListRows.Add.Range(1, 1).Value = TXT_auditorname.Value
    
        'Clear the UserForm text box after data is captured
        TXT_auditorname.Value = ""
        
        MsgBox "Auditor cadastrado com sucesso"
        
    End If

    reg_auditor.Close
   
    
End Sub

 

image.png.7cf0f4c333039b79b22a0c4c72f1e42c.png

Editado por Yago bezerra
Link para o comentário
Compartilhar em outros sites

6 respostass a esta questão

Posts Recomendados

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,1k
    • Posts
      651,8k
×
×
  • Criar Novo...