If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > lock and unlock cell

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-20-04, 16:22
Alexxx12 Alexxx12 is offline
Registered User
 
Join Date: Sep 2002
Location: NJ
Posts: 139
lock and unlock cell

hi,

xp & w2k
excel 2k

I am faced with a challenge I can not seem to overcome.
the user enters or paste data in column b. then he/she clicks on the Start Button. that action moves the focus to the d column and the current time is entered. At this point, the cell d where the time has been entered should be locked so that it can not be modidied. at the same time the cell has moved to the e column on the same row. When the user clicks on the Stop button (the same button), the same action just described should take effect and lock the e cell. The actual time spend between the start and stop cells is recorded in the f column and that one too, should be locked. The user will do that a number of time during the day. the total procedure caluculates the time difference and adds that value to column f


here is the code for the start/stop button


Private Sub CommandButton1_Click()
If ActiveCell.Value = "" And CommandButton1.Caption = "Start" Then

CommandButton1.Caption = "Stop"
Range("d"& CStr(ActiveCell.Row)) = time
Range("e" & CStr(ActiveCell.Row)).Activate
StartTimer

ElseIf ActiveCell.Value = "" And CommandButton1.Caption = "Stop" Then

StopTimer
StopIt
CommandButton1.Caption = "Start"
ActiveCell.Value = Time
total
end if
End Sub



one buttons:
to start and then the code changes to stop the time.

--------
Start |
--------

b c d e f
__________________________________________________ _____
richard | |4:14:59 PM | 4:15:03PM| 0:00:02|
________|__________|___________|_________|________ _____|
________|__________|___________|_________|________ _____|
________|__________|___________|_________|________ _____|
________|__________|___________|_________|________ _____|
________|__________|___________|_________|________ _____|
________|__________|___________|_________|________ _____|
________|__________|___________|_________|________ _____|
________|__________|___________|_________|________ _____|
________|__________|___________|_________|________ _____|
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On