Tema: excel
Ver Mensaje Individual
  #1 (permalink)  
Antiguo 01/03/2003, 00:52
Avatar de lmg7
lmg7
 
Fecha de Ingreso: agosto-2002
Mensajes: 93
Antigüedad: 22 años, 8 meses
Puntos: 0
A ver si te sirve...

Hacé lo siguiente:

- En el libro a auditar crea una hoja llamada Uso
- Seleciona Herramientas\Macro\Editor de Visual Basic (o Alt+F11).
- En el editor: Insertar\Módulo y te crea una módulo.
- Dentro del módulo copia el siguiente código:

Código:
Sub auto_open()
    Hoja = ActiveSheet.Name
    If ActiveSheet.Name <> "Uso" Then Sheets("Uso").Select
    ActiveSheet.Unprotect ("Luis")
    Cells(1, 1).Select
    Selection.End(xlDown).Select
    Selection.Offset(1, 0).Select
    ActiveCell.Value = Application.UserName
    Selection.Offset(0, 1).Select
    ActiveCell.Value = Now()
    ActiveSheet.Protect ("Luis")
    Sheets(Hoja).Select
    ActiveWorkbook.Save
End Sub
Sub auto_close()
    Hoja = ActiveSheet.Name
    If ActiveSheet.Name <> "Uso" Then Sheets("Uso").Select
    ActiveSheet.Unprotect ("Luis")
    Cells(1, 1).Select
    Selection.End(xlDown).Select
    Selection.Offset(0, 2).Select
    ActiveCell.Value = Now()
    Selection.Offset(0, 1).Select
    ActiveCell.FormulaR1C1 = "=(RC[-1]-RC[-2])*24"
    ActiveSheet.Protect ("Luis")
    Sheets(Hoja).Select
    ActiveWorkbook.Save
End Sub
- Remplazá Luis por una contraseña de tu elección.

Listo!, cada vez que alguien use el libro, en la hoja Uso, se almacenará el nombre del usuario, la fecha y hora del ingreso, la fecha y hora del egreso y la diferencia en horas. Además la hoja queda protegida contra escritura mediante tu contraseña.

Espero te sirva.

Si necesitas aclaraciones o detalles sobre el código me avisás.

Espero tu regalo para mi muy próximo cumpleaños .

Saludos.