al ejecutar macro se desactiva num lock
Tengo el mismo problema con un formulario automatizado, se vuelve incómodo porque me toca cambiar de vídeo ora trabajarlo , y al cambiar el foco de Excel al buscador de archivos o cualquier otra aplicación se desactiva el numlock, capslock y las luces del teclado que se asocian al botón Lock/Unlock
Aquí el código:
Dim cont, rw0, col0, rw1, col1, DHora, DMinu, Horal, Dant, pdat, sdat, sumar As Integer
Private Sub DatoAforado_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 13 Then
If TextBox3.Value <> nil Then
sumar = TextBox3.Value
Else
sumar = 1
End If
Operaciones
DatoAforado.Value = ""
DatoAforado.AutoTab = True
SendKeys "{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}"
End If
End Sub
Sub Hora_Change()
DHora = Entrada_Datos.Hora.Value
End Sub
Private Sub Minutos_Change()
DMinu = Entrada_Datos.Minutos.Value
End Sub
Sub Operaciones()
TextBox1.Value = "- o -"
TextBox2.Value = "- o -"
Horac = (DHora * 60 + DMinu) / (360 * 4) 'Hora calculada con el dato de entrada
Dant = 0
rw0 = 8
Horal = Hoja1.Cells(9, 2)
For i = 1 To 96
Horal = Hoja1.Cells(8 + i, 2).Value 'Hora Leida
If Abs(Horal - Horac) < (1 / 10000) Then
rw1 = rw0 + i
Horal = Hoja1.Cells(rw1, 2)
cdat = Len(DatoAforado.Value)
pdat = Mid(DatoAforado.Value, 1, 1) ' primer dato de la cadena de aforo digitado
If cdat = 3 Then
sdat = Mid(DatoAforado.Value, 2, 2) ' segundo dato de la cadena de aforo digitado
End If
If cdat = 2 Then
sdat = Mid(DatoAforado.Value, 2, 1) ' segundo dato de la cadena de aforo digitado
End If
Select Case pdat
Case "Q"
col0 = 32
TextBox1.Value = "Giro Derecho"
complemento
Case "A"
col0 = 18
TextBox1.Value = "Directo al Sur"
complemento
Case "Z"
col0 = 4
TextBox1.Value = "Giro Izquierdo"
complemento
Case "T"
col0 = 46
TextBox1.Value = "Retorno al Norte"
complemento
Case "W"
col0 = 88
TextBox1.Value = "Giro Derecho"
complemento
Case "S"
col0 = 74
TextBox1.Value = "Directo al Norte"
complemento
Case "X"
col0 = 60
TextBox1.Value = "Giro Izquierdo"
complemento
Case "G"
col0 = 102
TextBox1.Value = "Retorno al Sur"
complemento
Case "E"
col0 = 144
TextBox1.Value = "Giro Derecho"
complemento
Case "D"
col0 = 130
TextBox1.Value = "Directo al Oriente"
complemento
Case "C"
col0 = 116
TextBox1.Value = "Giro Izquierdo"
complemento
Case "B"
col0 = 158
TextBox1.Value = "Retorno al Occidente"
complemento
Case "R"
col0 = 200
TextBox1.Value = "Giro Derecho"
complemento
Case "F"
col0 = 186
TextBox1.Value = "Directo al Occidente"
complemento
Case "V"
col0 = 172
TextBox1.Value = "Giro Izquierdo"
complemento
Case "N"
col0 = 214
TextBox1.Value = "Retorno al Oriente"
complemento
Case Else
MsgBox "MAL DIGITADO"
End Select
TextBox3.Value = nil
pdat = ""
sdat = "99"
End If
Next
End Sub
Sub complemento()
Select Case sdat
Case "1" 'Selecciona Peatones
Dant = Hoja1.Cells(rw1, col0 + 0).Value 'Dato anterior leido en la hoja
Hoja1.Cells(rw1, col0 + 0) = Dant + sumar
TextBox2.Value = "Peatón"
Case "2" 'Selecciona Bicicletas
Dant = Hoja1.Cells(rw1, col0 + 1).Value 'Dato anterior leido en la hoja
Hoja1.Cells(rw1, col0 + 1) = Dant + sumar
TextBox2.Value = "Bicicleta"
Case "3" 'Selecciona Motos
Dant = Hoja1.Cells(rw1, col0 + 2).Value 'Dato anterior leido en la hoja
Hoja1.Cells(rw1, col0 + 2) = Dant + sumar
TextBox2.Value = "Moto"
Case "4" 'Selecciona autos
Dant = Hoja1.Cells(rw1, col0 + 3).Value 'Dato anterior leido en la hoja
Hoja1.Cells(rw1, col0 + 3) = Dant + sumar
TextBox2.Value = "Auto"
Case "5" 'Selecciona Colectivo
Dant = Hoja1.Cells(rw1, col0 + 4).Value 'Dato anterior leido en la hoja
Hoja1.Cells(rw1, col0 + 4) = Dant + sumar
TextBox2.Value = "Colectivo"
Case "6" 'Selecciona Buseta
Dant = Hoja1.Cells(rw1, col0 + 5).Value 'Dato anterior leido en la hoja
Hoja1.Cells(rw1, col0 + 5) = Dant + sumar
TextBox2.Value = "Buseta"
Case "7" 'Selecciona SITP Buseta
Dant = Hoja1.Cells(rw1, col0 + 6).Value 'Dato anterior leido en la hoja
Hoja1.Cells(rw1, col0 + 6) = Dant + sumar
TextBox2.Value = "SITP Buseta"
Case "8" 'Selecciona SITP Grande
Dant = Hoja1.Cells(rw1, col0 + 7).Value 'Dato anterior leido en la hoja
Hoja1.Cells(rw1, col0 + 7) = Dant + sumar
TextBox2.Value = "SITP Padrón"
Case "9" 'Selecciona alimentador
Dant = Hoja1.Cells(rw1, col0 + 8).Value 'Dato anterior leido en la hoja
Hoja1.Cells(rw1, col0 + 8) = Dant + sumar
TextBox2.Value = "Alimentador"
Case "11" 'Selecciona C2G
Dant = Hoja1.Cells(rw1, col0 + 9).Value 'Dato anterior leido en la hoja
Hoja1.Cells(rw1, col0 + 9) = Dant + sumar
TextBox2.Value = "C2P"
Case "22" 'Selecciona C2P
Dant = Hoja1.Cells(rw1, col0 + 10).Value 'Dato anterior leido en la hoja
Hoja1.Cells(rw1, col0 + 10) = Dant + sumar
TextBox2.Value = "C2G"
Case "33" 'Selecciona C3-C4
Dant = Hoja1.Cells(rw1, col0 + 11).Value 'Dato anterior leido en la hoja
Hoja1.Cells(rw1, col0 + 11) = Dant + sumar
TextBox2.Value = "C3 - C4"
Case "44" 'Selecciona C5
Dant = Hoja1.Cells(rw1, col0 + 12).Value 'Dato anterior leido en la hoja
Hoja1.Cells(rw1, col0 + 12) = Dant + sumar
TextBox2.Value = "C5"
Case "55" 'Selecciona >C5
Dant = Hoja1.Cells(rw1, col0 + 13).Value 'Dato anterior leido en la hoja
Hoja1.Cells(rw1, col0 + 13) = Dant + sumar
TextBox2.Value = "> C5"
Case Else
MsgBox "MAL DIGITADO"
End Select
End Sub