Bom dia,
Não manjo muito em VBA e como este tópico já estava aberto preferi utilizar e compartilhar a minha dificuldade.
bem meu problema é o seguinte:
tenho uma plan (MENU), através de botões me direciona para lanilha especificas e abre alguns formulários, um deles é o formulário de cadastro.
Meu maior problema é quando clico no botão Salvar, pois ao clicar no botão ele registra os dados na planilha que eu quero, porém ele abre essa planilha, gostaria que o formulário ficasse apenas na plan (MENU).
segue o código abaixo:
Private Sub SALVAR_Click()
ThisWorkbook.Worksheets("CPFf").Activate
Range("A5").Select
Do
If Not (IsEmpty(ActiveCell)) Then
ActiveCell.Offset(1, 0).Select
End If
'Confere se o campo nome foi preenchido
If tCod.Value = "" Then
MsgBox ("Campo Código é Obrigatório")
Exit Sub
tCod.SetFocus
Else
End If
Loop Until IsEmpty(ActiveCell) = True
ActiveCell.Value = tCod.Value
ActiveCell.Offset(0, 1).Value = TextBox2
ActiveCell.Offset(0, 2).Value = TextBox3
ActiveCell.Offset(0, 3).Value = TextBox4
ActiveCell.Offset(0, 4).Value = TextBox5
ActiveCell.Offset(0, 5).Value = TextBox6
ActiveCell.Offset(0, 6).Value = TextBox7
ActiveCell.Offset(0, 7).Value = TextBox8
ActiveCell.Offset(0, 8).Value = TextBox9
ActiveCell.Offset(0, 9).Value = TextBox10
ActiveCell.Offset(0, 10).Value = TextBox11
ActiveCell.Offset(0, 11).Value = TextBox12
ActiveCell.Offset(0, 12).Value = TextBox13
ActiveCell.Offset(0, 13).Value = TextBox14
ActiveCell.Offset(0, 14).Value = TextBox15
ActiveCell.Offset(0, 15).Value = TextBox16
ActiveCell.Offset(0, 16).Value = TextBox17
ActiveCell.Offset(0, 17).Value = TextBox18
ActiveCell.Offset(0, 18).Value = TextBox19
ActiveCell.Offset(0, 19).Value = TextBox20
ActiveCell.Offset(0, 20).Value = TextBox21
ActiveCell.Offset(0, 21).Value = TextBox22
ActiveCell.Offset(0, 22).Value = TextBox23
ActiveCell.Offset(0, 23).Value = TextBox24
ActiveCell.Offset(0, 24).Value = TextBox25
ActiveCell.Offset(0, 25).Value = TextBox26
ActiveCell.Offset(0, 26).Value = TextBox27
ActiveCell.Offset(0, 27).Value = TextBox28
ActiveCell.Offset(0, 28).Value = TextBox28
ActiveCell.Offset(0, 29).Value = TextBox30
ActiveCell.Offset(0, 30).Value = TextBox31
ActiveCell.Offset(0, 31).Value = TextBox32
ActiveCell.Offset(0, 32).Value = TextBox33
ActiveCell.Offset(0, 33).Value = TextBox34
ActiveCell.Offset(0, 34).Value = TextBox35
ActiveCell.Offset(0, 35).Value = TextBox36
ActiveCell.Offset(0, 36).Value = TextBox37
ActiveCell.Offset(0, 37).Value = TextBox38
ActiveCell.Offset(0, 38).Value = TextBox39
ActiveCell.Offset(0, 39).Value = TextBox40
ActiveCell.Offset(0, 40).Value = TextBox41
ActiveCell.Offset(0, 41).Value = TextBox42
tCod.Value = Empty
TextBox2.Value = Empty
TextBox3.Value = Empty
TextBox4.Value = Empty
TextBox5.Value = Empty
TextBox6.Value = Empty
TextBox7.Value = Empty
TextBox8.Value = Empty
TextBox9.Value = Empty
TextBox10.Value = Empty
TextBox11.Value = Empty
TextBox12.Value = Empty
TextBox13.Value = Empty
TextBox14.Value = Empty
TextBox15.Value = Empty
TextBox16.Value = Empty
TextBox17.Value = Empty
TextBox18.Value = Empty
TextBox19.Value = Empty
TextBox20.Value = Empty
TextBox21.Value = Empty
TextBox22.Value = Empty
TextBox23.Value = Empty
TextBox24.Value = Empty
TextBox25.Value = Empty
TextBox26.Value = Empty
TextBox27.Value = Empty
TextBox28.Value = Empty
TextBox29.Value = Empty
TextBox30.Value = Empty
TextBox31.Value = Empty
TextBox32.Value = Empty
TextBox33.Value = Empty
TextBox34.Value = Empty
TextBox35.Value = Empty
TextBox36.Value = Empty
TextBox37.Value = Empty
TextBox38.Value = Empty
TextBox39.Value = Empty
TextBox40.Value = Empty
TextBox41.Value = Empty
TextBox42.Value = Empty
MsgBox "Cadastro Efetuado Com Sucesso!!!", vbInformation, "ZUFER TECNOLOGIA E FERRAMENTARIA LTDA."
ThisWorkbook.Worksheets("CPFf").Activate = False
End Sub
Sempre que clico no botão SALVAR, ele abre atras do formulário a planilha(CPFf) onde os dados ficam armazenados, queria que atrás do formulário ficasse sempre a plan menu e nao mudasse quando fosse realizado o loop.
podem me ajudar?
agradeço desde já pela força!!!