Ao inserir um código no fórum, utilize blocos de código. Para utilizar essa
ferramenta, clique no botão cuja legenda é “Inserir bloco de código” na barra
do editor de mensagens do fórum.
---
Declare variáveis!
http://www.ambienteoffice.com.br/officevba/declaracao_de_variavel/
---
Private Sub SALVAR_Click()
Dim strErro As String
If Cliente = "" Then strErro = "Escolher cliente, Fornecedor, ou Colaborador"
If RAZÃO = "" Then strErro = "Preencha o campo Nome/Razão Social"
If CPF = "" Then strErro = "Preencha o campo CPF/ CNPJ"
If FONE1 = "" Then strErro = "Peencha o campo Fone1"
If strErro = "" Then
MsgBox strErro, vbCritical
Exit Sub
End If
totalregistro = Worksheets("BANCO DE DADOS").UsedRange.Rows.Count + 1
With Worksheets("BANCO DE DADOS")
.Cells(totalregistro, 1) = Cliente
.Cells(totalregistro, 2) = Função
.Cells(totalregistro, 3) = RAZÃO
.Cells(totalregistro, 4) = FANTASIA
.Cells(totalregistro, 5) = Pessoa
.Cells(totalregistro, 6) = CPF
.Cells(totalregistro, 7) = INSCRIÇÃO
.Cells(totalregistro, 8) = FONE1
.Cells(totalregistro, 9) = FONE2
.Cells(totalregistro, 10) = FAX
.Cells(totalregistro, 11) = CELULAR
.Cells(totalregistro, 12) = CONTATO
.Cells(totalregistro, 13) = EMAIL1
.Cells(totalregistro, 14) = EMAIL2
.Cells(totalregistro, 15) = SITE
.Cells(totalregistro, 16) = CEP
.Cells(totalregistro, 17) = ENDEREÇO
.Cells(totalregistro, 18) = NÚMERO
.Cells(totalregistro, 19) = BAIRRO
.Cells(totalregistro, 20) = CIDADE
.Cells(totalregistro, 21) = estado
.Cells(totalregistro, 22) = OBSERVAÇÕES
End With
MsgBox "Salvo com sucesso", vbInformation
End Sub
Felipe Costa Gualberto - http://www.ambienteoffice.com.br