Ejecutar código con tecla Enter y botón (CommandButton)
Para Dante
Hola amigo.
Te pido una más para lo siguiente; trato de usar esta macro así pero no me resulta
Macro: anteriormente era Private Sub CommandButton1_Click() Directa desde el boton ahora la pase a un modulo normal y desde ahi la llamo con un Call
Sub Comando() 'Validar Nuevo
Dim sonsat As Long
'Dim vcS As String
'Dim vtx As String
Dim i As Double
Dim vcS()
Dim vtx()
Application.ScreenUpdating = False
'1º Array de nombre de control
vcS = Array("Textbox1", "Textbox2", "Textbox3", "Textbox4", "TextBox8", "TextBox10", "TextBox12")
'2º Array de mensaje a presentar segun el orden de los controles
vtx = Array("Minimo Nombre y Apellido", "Nombre de compañia", "Dirección de residencia", _
"Ciudad donde reside", "# de Teléfono para contacto", "Dirección de E-Mail", "Ingresos Estimados")
For i = LBound(vcS) To UBound(vcS)
If Controls(vcS(i)) = Empty Then
MsgBox "Debes Introducir " & vtx(i), vbExclamation, "ALTA"
Controls(vcS(i)).SetFocus 'tira el focu al control designado
Exit Sub
End If
Next
If Not IsNumeric(TextBox12.Text) Then 'Solo para ingreso de números
MsgBox "Por favor, introduzca en Ingresos Estimados SOLO valor numérico.", vbExclamation
TextBox12.SetFocus
Exit Sub
End If
sonsat = Sheets("Data").[a65536].End(3).Row + 1
Call Main 'Progress Bar
Cells(sonsat, 1) = TextBox1
Cells(sonsat, 2) = TextBox2
Cells(sonsat, 3) = TextBox3
Cells(sonsat, 4) = TextBox4
Cells(sonsat, 5) = TextBox5
Cells(sonsat, 6) = TextBox6
Cells(sonsat, 7) = TextBox7
Cells(sonsat, 8) = TextBox8
Cells(sonsat, 9) = TextBox9
Cells(sonsat, 10) = TextBox10
Cells(sonsat, 11) = TextBox11
Cells(sonsat, 12) = TextBox12
MsgBox "Registro completo"
Call Ordenar_Data
ListBox1.List = Sheets("Data").Range("a2:l" & [a65536].End(3).Row).Value 'Actualiza listbox
TextBox14.Value = ListBox1.ListCount
Application.ScreenUpdating = True
End SubPara poder usar tambien en boton (CommandButton1)
Private Sub CommandButton1_Click() Call Comando End Sub
Si uso el CommandButton1, todo va bien
pero si uso esto, ya no me funciona como con el boton CommandButton1:
Private Sub textBox12_keydown(ByVal keycode As MSforms.ReturnInteger, ByVal Shift As Integer) If keycode = 13 Then Comando End Sub
Solo me funciona si el focu esta en el TextBox12 y quiero que me funcione tal como es la macro Sub Comando cuando la ejecuto desde el boton CommandButton1
1 respuesta
Respuesta de Dante Amor
2