Using the following example:
Book1 |
---|
|
---|
| A | B | C | D | E | F |
---|
1 | Job# | Oper# | Part# | QtyComplete | Clock-InTime | Clock-OutTime |
---|
2 | 123 | 24 | 345 | 200 | 1/17/2005-10:00:00AM | 1/17/2005-11:15:20AM |
---|
3 | 456 | 12 | 567 | 150 | 1/17/2005-10:15:05AM | 1/17/2005-11:22:18AM |
---|
|
---|
The following Command button code will prompt you to enter a new Job #, Operator # & Part #, then add a start Date & Time. The second bit will prompt you for a Job #, find it, then prmopt you for a Quantity and add the end Date & Time.<<font face=Tahoma><SPAN style="color:#00007F">Option</SPAN><SPAN style="color:#00007F">Explicit</SPAN><SPAN style="color:#00007F">Private</SPAN><SPAN style="color:#00007F">Sub</SPAN> CommandButton1_Click()
<SPAN style="color:#007F00">' Add a new job</SPAN>
<SPAN style="color:#00007F">Dim</SPAN> LastRow<SPAN style="color:#00007F">As</SPAN><SPAN style="color:#00007F">Object</SPAN>
<SPAN style="color:#00007F">Set</SPAN> LastRow = Sheets("Sheet1").Range("A65536").End(xlUp)
<SPAN style="color:#00007F">With</SPAN> LastRow
.Offset(1, 0) = InputBox("Please enter a Job #", "Job #")
.Offset(1, 1) = InputBox("Please enter an Operator #", "Operator #")
.Offset(1, 2) = InputBox("Please enter a Part #", "Part #")
.Offset(1, 4) =<SPAN style="color:#00007F">Date</SPAN> & " - " & Time
<SPAN style="color:#00007F">End</SPAN><SPAN style="color:#00007F">With</SPAN>
<SPAN style="color:#00007F">End</SPAN><SPAN style="color:#00007F">Sub</SPAN><SPAN style="color:#00007F">Private</SPAN><SPAN style="color:#00007F">Sub</SPAN> CommandButton2_Click()
<SPAN style="color:#007F00">' Update Clock-Out time</SPAN>
<SPAN style="color:#00007F">Dim</SPAN> x<SPAN style="color:#00007F">As</SPAN><SPAN style="color:#00007F">Integer</SPAN>
<SPAN style="color:#00007F">Dim</SPAN> c<SPAN style="color:#00007F">As</SPAN> Range
<SPAN style="color:#00007F">Dim</SPAN> FirstAddress
x = Application.InputBox("Please enter a job #", "Job # Search", Type:=1)
<SPAN style="color:#007F00">' Adjust range as necessary</SPAN>
<SPAN style="color:#00007F">With</SPAN> Worksheets(1).Range("A1:A500")
<SPAN style="color:#00007F">Set</SPAN> c = .Find(x, LookIn:=xlValues)
<SPAN style="color:#00007F">If</SPAN><SPAN style="color:#00007F">Not</SPAN> c<SPAN style="color:#00007F">Is</SPAN><SPAN style="color:#00007F">Nothing</SPAN><SPAN style="color:#00007F">Then</SPAN>
FirstAddress = c.Address
<SPAN style="color:#00007F">Do</SPAN>
<SPAN style="color:#007F00">' Update Quantity Completed</SPAN>
c.Offset(, 3) = Application.InputBox("Please enter the Quantity Completed", _
"Quantity Completed", Type:=1)
<SPAN style="color:#007F00">' Add Clock-Out time</SPAN>
c.Offset(, 5) =<SPAN style="color:#00007F">Date</SPAN> & " - " & Time
<SPAN style="color:#00007F">Loop</SPAN><SPAN style="color:#00007F">While</SPAN><SPAN style="color:#00007F">Not</SPAN> c<SPAN style="color:#00007F">Is</SPAN><SPAN style="color:#00007F">Nothing</SPAN> And c.Address<> FirstAddress
<SPAN style="color:#00007F">End</SPAN><SPAN style="color:#00007F">If</SPAN>
<SPAN style="color:#00007F">End</SPAN><SPAN style="color:#00007F">With</SPAN>
<SPAN style="color:#00007F">End</SPAN><SPAN style="color:#00007F">Sub</SPAN></FONT>
Smitty