-
Total de itens
8 -
Registro em
-
Última visita
Posts postados por Yago bezerra
-
-
Corrigido! deu certo.
inseri um exit sub para que não ocorra o preenchimento de celula vazia.
Obrigado!. segue código para uso da comunidade
Sub B_cadastrarauditor_Click()
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"
Exit Sub
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 IfUnload reg_auditor
End Sub -
Fiz a alteração trocando
"reg_auditor.close" para "Unload reg_auditor"
sobre o exemplo acredito que não tem um exemplo direto pois é um sistema de gerenciamento de 5S que estou tentando criar na empresa, o mais próximo disso seria um formulário de cadastro com userform.
eu sou novo aqui(até em forums haha), então descupe por esses erros.
excel não consegui postar, mas vou deixar o código em texto.
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
Dim OB_off As MSForms.OptionButton
Dim OB_man As MSForms.OptionButton
Dim ws As Worksheet
Dim nextRow As LongIf OB_off.Enabled And OB_man.Enabled Then
With OB_off
MsgBox "Selecione em qual área será cadastrado o auditor"
End With
End If
If TXT_auditorname = "" Then
MsgBox "Preencha o nome do auditor"ElseIf 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 IfUnload reg_auditor
End Sub -
-
Deu boa!!
agora estou com outro problema hahaha
mas esse foi resolvido!
Obrigado.
-
-
-
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 LongIf 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 Ifreg_auditor.Close
End Sub
VBA Para cadastro com error de compilação: O objeto With precisa ser de tipo definido pelo usuário, Object ou Variant
em VBA
Postado
Entendi, Obrigado !
estou andando no projeto, qualquer coisa volto.
é indicado abrir outra pergunta ou continuo sempre no mesmo post ?