I have started to create a excel with vba that should put a timestamps in cells a row when pressed.
On same sheet I have a counter, calculation of "cycletime" and also a conditional formating to highlight if a cycle is larger that set value (also displayed in sheet)
This is the code used for Clickbutton:
Private Sub Click()
If koll = 1 Then
Worksheets("User Data").Protect Contents:=False
Worksheets("User Data").Cells(countunit, 1) = Format(Now, "mm/dd/yyyy HH:mm:ss")
countunit = countunit + 1
koll = 1
Cells(2, 4) = "Antal enheter"
Cells(3, 4) = countunit - 9
End If
Worksheets("User Data").Protect Contents:=True
End Sub
Initial question is how do I create a sub that make it possible to close and open the file and it continues from last position.
Current I need to use a reset Sub to make ut work but the I lose previous data
This is the code for reseting
Private Sub Reset_Click()
countunit = 9
koll = 1
Worksheets("User Data").Protect Contents:=False
Worksheets("Background Data").Protect Contents:=False
Worksheets("User Data").Cells(8, 1) = "Timestamp for unit to station"
Worksheets("User Data").Cells(3, 4) = 0
Worksheets("User Data").Range("A9:A800").ClearContents
Worksheets("User Data").Range("C9:C800").ClearContents
'Worksheets("Data").Cells.ClearContents
Worksheets("User Data").Cells(8, 1) = "Timestamp for unit to station"
Worksheets("User Data").Cells(2, 4) = "Number of units"
Worksheets("User Data").Cells(9, 1) = 0
Worksheets("Background Data").Cells(2, 6) = "Value for row calculation"
Worksheets("Background Data").Cells(3, 6) = countunit
Worksheets("Background Data").Cells(4, 6) = "Uppdated"
Worksheets("Background Data").Cells(4, 6) = Format(Now, "mm/dd/yyyy HH:mm:ss")
Worksheets("User Data").Protect Contents:=True
Worksheets("Background Data").Protect Contents:=True
End Sub
On same sheet I have a counter, calculation of "cycletime" and also a conditional formating to highlight if a cycle is larger that set value (also displayed in sheet)
This is the code used for Clickbutton:
Private Sub Click()
If koll = 1 Then
Worksheets("User Data").Protect Contents:=False
Worksheets("User Data").Cells(countunit, 1) = Format(Now, "mm/dd/yyyy HH:mm:ss")
countunit = countunit + 1
koll = 1
Cells(2, 4) = "Antal enheter"
Cells(3, 4) = countunit - 9
End If
Worksheets("User Data").Protect Contents:=True
End Sub
Initial question is how do I create a sub that make it possible to close and open the file and it continues from last position.
Current I need to use a reset Sub to make ut work but the I lose previous data
This is the code for reseting
Private Sub Reset_Click()
countunit = 9
koll = 1
Worksheets("User Data").Protect Contents:=False
Worksheets("Background Data").Protect Contents:=False
Worksheets("User Data").Cells(8, 1) = "Timestamp for unit to station"
Worksheets("User Data").Cells(3, 4) = 0
Worksheets("User Data").Range("A9:A800").ClearContents
Worksheets("User Data").Range("C9:C800").ClearContents
'Worksheets("Data").Cells.ClearContents
Worksheets("User Data").Cells(8, 1) = "Timestamp for unit to station"
Worksheets("User Data").Cells(2, 4) = "Number of units"
Worksheets("User Data").Cells(9, 1) = 0
Worksheets("Background Data").Cells(2, 6) = "Value for row calculation"
Worksheets("Background Data").Cells(3, 6) = countunit
Worksheets("Background Data").Cells(4, 6) = "Uppdated"
Worksheets("Background Data").Cells(4, 6) = Format(Now, "mm/dd/yyyy HH:mm:ss")
Worksheets("User Data").Protect Contents:=True
Worksheets("Background Data").Protect Contents:=True
End Sub