Ir para conteúdo
Fórum Script Brasil

PaiDeLaura

Membros
  • Total de itens

    3
  • Registro em

  • Última visita

Sobre PaiDeLaura

PaiDeLaura's Achievements

0

Reputação

  1. Bom dia! Estou desenvolvendo um sistema em VBA e busquei o código na IA. As outras funções funcionam perfeitamente, porém, as funções de alterar e excluir não retornam os dados a partir do número de ofício. Vou postar o código abaixo: // Alterar Private Sub cmdAlterar_Click() Dim linha As Long Dim encontrado As Boolean encontrado = False If Not ValidarCampos Then Exit Sub linha = 2 ' Começar da linha 2 With Sheets("AgendaEventos") Do While .Cells(linha, 1).Value <> "" If .Cells(linha, 1).Value = Me.txtNumOficio.Text Then ' Atualizar os dados .Cells(linha, 2).Value = Me.txtEvento.Text .Cells(linha, 3).Value = Me.cmbCategoria.Text .Cells(linha, 4).Value = Me.txtResponsavel.Text .Cells(linha, 5).Value = Me.txtCpfCnpj.Text .Cells(linha, 6).Value = Me.txtTelefone.Text .Cells(linha, 7).Value = Me.txtLocal.Text .Cells(linha, 8).Value = Me.txtData.Text .Cells(linha, 9).Value = Me.cmbEstimativa.Text .Cells(linha, 10).Value = Me.cmbSituacao.Text encontrado = True Exit Do End If linha = linha + 1 Loop End With If encontrado Then MsgBox "Registro alterado com sucesso!", vbInformation Call cmdLimpar_Click Else MsgBox "Número de Ofício não encontrado para alteração!", vbExclamation End If End Sub //excluir Private Sub cmdExcluir_Click() If txtNumOficio.Value = "" Then MsgBox "Informe o Número do Ofício para excluir.", vbExclamation Exit Sub End If Dim ws As Worksheet Set ws = ThisWorkbook.Sheets("AgendaEventos") Dim linha As Long linha = ProcurarEvento(txtNumOficio.Value) If linha = 0 Then MsgBox "Evento não encontrado!", vbExclamation Else ws.Rows(linha).Delete MsgBox "Evento excluído com sucesso!", vbInformation Call cmdLimpar_Click End If End Sub //validar campos Private Function ValidarCampos() As Boolean ValidarCampos = False If Me.txtNumOficio.Text = "" Or _ Me.txtEvento.Text = "" Or _ Me.cmbCategoria.Text = "" Or _ Me.txtResponsavel.Text = "" Or _ Me.txtCpfCnpj.Text = "" Or _ Me.txtTelefone.Text = "" Or _ Me.txtLocal.Text = "" Or _ Me.txtData.Text = "" Or _ Me.cmbEstimativa.Text = "" Or _ Me.cmbSituacao.Text = "" Then MsgBox "Preencha todos os campos obrigatórios!", vbExclamation Exit Function End If ValidarCampos = True End Function Queria melhorar esse código trazendo os dados para alteração/exclusão, podem me ajudar? No aguardo e desde já agradeço []'s
  2. Bom dia, Tenho um pequeno sistema de registro de denúncias. O cadastro funciona, de boa, mas a pesquisa quando vou escolher as datas, aparece esse erro aqui: Erro em tempo de execução '-2147467259(80004005)': Erro não especificado Eis o código: Private Sub btnPesquisar_Click() Dim linhaFinal, linha, x As Integer ListBox1.Clear // o erro para aqui e não depura mais linhaFinal = Planilha1.Cells(Rows.Count, 1).End(xlUp).Row x = 0 For linha = 2 To linhaFinal If Planilha1.Cells(linha, 1).Value >= MonthView1 And Planilha1.Cells(linha, 1).Value <= MonthView2 Then ListBox1.AddItem Planilha1.Cells(linha, 1).Value ListBox1.List(x, 1) = Planilha1.Cells(linha, 2).Value ListBox1.List(x, 2) = Planilha1.Cells(linha, 3).Value ListBox1.List(x, 3) = Planilha1.Cells(linha, 4).Value ListBox1.List(x, 4) = Planilha1.Cells(linha, 5).Value x = x + 1 End If Next End Sub Porque isso acontece e o que pode ser feito? Preciso da ajuda dos colegas! Forte abraço! Resposta Rápida Resposta 1
  3. Boa tarde!Gostaria de saber ou quem puder me ajudar, fazer uma validação que, ao aparecer a caixa do Inputbox e ao clicar no campo vazio, fornecer uma mensagem de campo obrigatório e logo após aparecer novamente para digitar. Vou colocar o código aqui:Sub cadastro_agenda()nome = InputBox("Digite o nome:")telefone = InputBox("Digite o telefone:")setor = InputBox("Digite o setor:")lin = Range("A1").End(xlDown).Row + 1Cells(lin, 1) = nomeCells(lin, 2) = telefoneCells(lin, 3) = setor End SubEspero que possam me dar essa luz! Forte abraço!
×
×
  • Criar Novo...