ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help needed on Macro (https://www.excelbanter.com/excel-programming/372210-help-needed-macro.html)

Gary

Help needed on Macro
 
Hi,

Heres what am trying to accomplish.

two columns (protected), column A - Start Time and Column B End Time.

now when a person starts working he needs to enter the current time
in...say... A1. I want that person to press a key combination that would run
a macro which will unprotect the both the columns, enter the current time in
the Selected cell, and protect both the columns again. same at the time of
End Time.

now I want the macro to enter the date only in the selected cell. but it
should unprotect and Protect both, entire columns. Also, when the columns
are protected, the user should be able to select the cells. please help.

Thanks.
Gary



Kevin B

Help needed on Macro
 
Perhaps this will work for you, copy it into a module and when your finished,
click TOOLS in the menu, click MACRO, MACROS. Select the macro named
TimeStamp and then click to OPTIONS command button and assign it the key
combination of your choice:

Sub TimeStamp()
Application.ScreenUpdating = False
ActiveSheet.Protect DrawingObjects:=False, Contents:=False,
Scenarios:=False
Columns("A:B").Locked = False
ActiveCell.Value = TimeSerial(Hour(Time), Minute(Time), Second(Time))
Columns("A:B").Locked = True
Selection.NumberFormat = "[$-409]h:mm AM/PM;@"
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Application.ScreenUpdating = True
End Sub
--
Kevin Backmann


"Gary" wrote:

Hi,

Heres what am trying to accomplish.

two columns (protected), column A - Start Time and Column B End Time.

now when a person starts working he needs to enter the current time
in...say... A1. I want that person to press a key combination that would run
a macro which will unprotect the both the columns, enter the current time in
the Selected cell, and protect both the columns again. same at the time of
End Time.

now I want the macro to enter the date only in the selected cell. but it
should unprotect and Protect both, entire columns. Also, when the columns
are protected, the user should be able to select the cells. please help.

Thanks.
Gary





All times are GMT +1. The time now is 12:07 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com