In the ThisWorkBook class module
Private Sub Workbook_Open()
Dim lngRow As Long
'// Refers to the sheet code name - not the Tab name
'// Users do not have access to the code outside of the VBA
'// environment,, and the tab name can be changed without
'// affecting the code.
lngRow = Sheet1.Range("A" & Rows.Count).End(xlUp).Offset(1).Row
With Sheet1
.Cells(lngRow, 1).Value = "GLA-2013-" & Format$(lngRow - 1, "00000")
.Cells(lngRow, 2).Value = Now()
End With
'// Reset the Dirty flag. If the workbook is unloaded with
'// no further changes then user is not prompted to save.
'// If they make any further changes then they will save in any case.
ThisworkBook.Saved = true
End Sub
IMO, not a good idea to save the workbook in code - it may have been opened accidentally, for example. If the user 'uses' the new line then they will save. If not, then the new line will be discarded/
Bookmarks