Formularios VBA en excel

Estoy realizando un directorio y quisiera que a la hora de introducir mis datos en el formulario que ya he realizado me los clasifique en las distintas hojas que he creado para cada sector pero que tambien se quede registrado en la hoja principal que seria como el directorio general. A parte he creado botones para que se pudiera mostrar la hoja del sector en pantalla completa pero no se como hacerlo.

1 respuesta

Respuesta
1
Pues sin ver el código no puedo ayudar.
Tines Razón, Bueno este es mi codigo:
Private Sub CommandButton1_Click() 'INSERTAR DATOS
Dim strfila$
Worksheets("Directorio").Activate
Worksheets("Directorio").Unprotect
Dim fila As String
[A65536].End(xlUp).Offset(1, 0).Select
strfila$ = ActiveCell.Row
ActiveCell = Val(TextBox1)
Range("B" + strfila$) = TextBox2
Range("C" + strfila$) = TextBox3
Range("D" + strfila$) = TextBox4
Range("E" + strfila$) = TextBox5
Range("F" + strfila$) = TextBox6
Range("G" + strfila$) = TextBox7
Range("H" + strfila$) = TextBox8
Range("I" + strfila$) = TextBox9
Range("J" + strfila$) = TextBox10
Range("K" + strfila$) = TextBox11
Range("L" + strfila$) = TextBox12
Range("M" + strfila$) = TextBox13
Range("N" + strfila$) = TextBox14
Range("O" + strfila$) = TextBox15
Range("P" + strfila$) = TextBox16
Range("Q" + strfila$) = TextBox17
Range("R" + strfila$) = TextBox18
Range("S" + strfila$) = TextBox19
Range("T" + strfila$) = TextBox20
Range("U" + strfila$) = TextBox21
Range("v" + strfila$) = ComboBox1
Worksheets("Directorio").Protect
Range("A1").End(xlDown).Select
TextBox1 = ActiveCell.Value + 1
TextBox2 = "": TextBox3 = "": TextBox4 = "": TextBox5 = "": TextBox6 = "": TextBox7 = "": TextBox8 = "": TextBox9 = "": TextBox10 = "": TextBox11 = "": TextBox12 = "": TextBox13 = "": TextBox14 = "": TextBox15 = "": TextBox16 = "": TextBox17 = "": TextBox18 = "": TextBox19 = "": TextBox20 = "": TextBox21 = "": ComboBox1 = ""
Exit Sub
seguir:
TextBox2.SetFocus
End Sub
---------------------------------------------------------------------------------------
Private Sub CommandButton2_Click() 'BUSCAR DATOS
u = Hoja2.Range("A" & Rows.Count).End(xlUp).Row
TextBox1 = Empty
With Hoja2.Range("B1:B" & u)
    Set c = .Find(TextBox2, LookIn:=xlValues, LookAt:=xlWhole)
    If Not c Is Nothing Then
        TextBox3 = c.Offset(0, 1): TextBox4 = c.Offset(0, 2)
        TextBox5 = c.Offset(0, 3): TextBox6 = c.Offset(0, 4)
        TextBox7 = c.Offset(0, 5): TextBox8 = c.Offset(0, 6)
        TextBox9 = c.Offset(0, 7): TextBox10 = c.Offset(0, 8)
        TextBox11 = c.Offset(0, 9): TextBox12 = c.Offset(0, 10)
        TextBox13 = c.Offset(0, 11): TextBox14 = c.Offset(0, 12)
        TextBox15 = c.Offset(0, 13): TextBox16 = c.Offset(0, 14)
        TextBox17 = c.Offset(0, 15): TextBox18 = c.Offset(0, 16)
        TextBox19 = c.Offset(0, 17): TextBox20 = c.Offset(0, 18)
        TextBox21 = c.Offset(0, 19): ComboBox1 = c.Offset(0, 20)
        TextBox1 = c.Offset(0, -1)
    Else
        MsgBox "EL VALOR NO EXISTE"
    End If
End With
End Sub
---------------------------------------------------------------------------------
Private Sub CommandButton3_Click() 'BOTON SALIR
Unload UserForm1
'ActiveWorkbook.Close True
Worksheets("Inicio").Activate
End Sub
---------------------------------------------------------------------------------
Private Sub CommandButton4_Click()
Worksheets("Agricola").Select
Unload Me
End Sub
---------------------------------------------------------------------------------
Private Sub CommandButton5_Click()
Worksheets("Ganadero").Select
Unload Me
End Sub
---------------------------------------------------------------------------------
Private Sub CommandButton7_Click()
Worksheets("Piscicola").Select
Unload Me
End Sub
---------------------------------------------------------------------------------
Private Sub CommandButton8_Click()
Worksheets("Forestal").Select
Unload Me
End Sub
---------------------------------------------------------------------------------
Private Sub CommandButton9_Click()
Worksheets("Turismo").Select
Unload Me
End Sub
---------------------------------------------------------------------------------
Private Sub CommandButton10_Click()
Worksheets("Otros").Select
Unload Me
End Sub
--------------------------------------------------------------------------------
Private Sub CommandButton6_Click() LIMPIAR FORMULARIO
UserForm1.TextBox2.Value = ""
UserForm1.TextBox3.Value = ""
UserForm1.TextBox4.Value = ""
UserForm1.TextBox5.Value = ""
UserForm1.TextBox6.Value = ""
UserForm1.TextBox7.Value = ""
UserForm1.TextBox8.Value = ""
UserForm1.TextBox9.Value = ""
UserForm1.TextBox10.Value = ""
UserForm1.TextBox11.Value = ""
UserForm1.TextBox12.Value = ""
UserForm1.TextBox13.Value = ""
UserForm1.TextBox14.Value = ""
UserForm1.TextBox15.Value = ""
UserForm1.TextBox16.Value = ""
UserForm1.TextBox17.Value = ""
UserForm1.TextBox18.Value = ""
UserForm1.TextBox19.Value = ""
UserForm1.TextBox20.Value = ""
UserForm1.TextBox21.Value = ""
UserForm1.ComboBox1.Value = ""
seguir:
TextBox2.SetFocus
End Sub
------------------------------------------------------------------------------
Private Sub UserForm_Initialize() 'AL INICIAR FORMULARIO
Label23.Caption = Date
'Cargamos combobox
ComboBox1.AddItem Worksheets("Clase").Range("a1")
ComboBox1.AddItem Worksheets("Clase").Range("a2")
ComboBox1.AddItem Worksheets("Clase").Range("a3")
ComboBox1.AddItem Worksheets("Clase").Range("a4")
ComboBox1.AddItem Worksheets("Clase").Range("a5")
ComboBox1.AddItem Worksheets("Clase").Range("a6")
Worksheets("Directorio").Activate
Range("a2").Select
If ActiveCell = Empty Then
TextBox1 = 1
Else
Range("a1").End(xlDown).Select
TextBox1 = ActiveCell.Value + 1
End If
End Sub
--------------------------------------------------------------------------------
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
    If CloseMode = vbFormControlMenu Then
        Cancel = True
        MsgBox "POR FAVOR, PARA SALIR USA EL BOTON CORRESPONDIENTE", vbInformation, "LEA"
    End If
End Sub
Lo que quiero es que al llenar el formulario, la Hoja "Directorio" se vaya llenando pero que segun el sector en este caso para utilizar el ConboBox1 "Agricola, ganadero, piscicola,..." vaya copiando a su hoja respectiva.
Espero poder explicarme y que me puedas ayudar..
en esta direccion puedes encontrar mi archivo
http://www.mundoverde.netii.net/Webs/Directorio.xlsm
Viendo tu hoja podrías utilizar alguna rutina que diga.
If ComboBox1.Text = "Agrícola" Then Hoja("Agrícola").Select
   RestoDeTuCodigo
End If
O podrías hacerlo con un Select Case ... End Select

Añade tu respuesta

Haz clic para o