Ingresar hora sin repetir y cálculo con horario

Srta. Elsa Matilde, favor solicitó su ayuda : Tengo 2 hojas:DATOS con A nombres, B código, hoja2 CONTROL con A código, B fecha, C diasem, D hora, E observ, F tpo y 1 userform1 con 1 txtcod, 1 txthoy, 1 cmdentrada, 2 label : lblhora, lblobs. La macro no funciona correctamente:lo que deseo es que no repita su entrada el mismo día y calcule la hora que ingresó con su horario

Private sub cmdentrada_click()

'si existe el codigo de hoja datos col B sale msg que no vuelva a escribir bien:

Sheets("datos"), select

Set busca4=activesheet. La range("B:B").find(txtcod), lookin:=xlvalues ,lookat:=xlwhole.

If busca4 is nothing then

Msg"UD.dígito mal escriba bien"

Set busca4=nothing

Endif

Ing=0

Sheets("control").select

Set busca5=activesheet. Range("A:A").find(txtcod, lookin:=xlvalues, lookat:=xlwhole)

If not busca5 is nothing then

Primco=busca5.address

Do

If busca5.offset(0,1)=cdate(txthoy) then

Msg"UD.ya registró su entrada"

Else

Fila=2

Col="A"

Do while true

If isempty(cells(fila,col)), then exit do

Fila=fila + 1

Loop

Cells(fila,"A")= txtcod.text

Cells(fila,"B")=format(now,"Dd/mm/yyyy")

Cells(fila,"C")=format(now,"dddd")

Cells("fila,"D")=format(now,"hh:mm")

'horario de lun a Vier 7 a 3 pm sab 7 a 12.

If lblhora.caption >7 then

Lblobs.caption=".llegó tarde"

Else

Lblobs.caption="muy bien"

Endif

Cells(fila,"E")=Lblobs.caption

Cells(fila,"F")=cells(fila," D").value - 7:00)

Ing=1

Endif

Endif

Set busca5=activesheet. Range("A:A").findnext(busca5)

Loop while not busca5 is nothing and busca5.address <>Primco and Ing=0

Set busca5=nothing

End sub

1 Respuesta

Respuesta
1

Ya corregí el error y salió Ok

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas