Private Sub Workbook_Open()
Const sAPPLICATION As String = "Excel"
Const sSECTION As String = "Invoice"
Const sKEY As String = "Invoice_key"
Const nDEFAULT As Long = 1&
Dim nNumber As Long
With ThisWorkbook.Sheets("Job Ticket")
With .Range("E10")
If IsEmpty(.Value) Then
.Value = Date
.NumberFormat = "dd-mmm-yy"
End If
End With
With .Range("Z10")
If IsEmpty(.Value) Then
nNumber = GetSetting(sAPPLICATION, sSECTION, sKEY, nDEFAULT)
.NumberFormat = "@"
.Value = Format(nNumber, "0000")
SaveSetting sAPPLICATION, sSECTION, sKEY, nNumber + 1&
End If
End With
End With
End Sub
SHG - You were able to help me last time with this code, I'd appreciate it if you could lend me your expertise one more time.
The code works however I noticed that my date wasn't changing. After looking at the code I realized why. The line "If IsEmpty(.Value) Then .Value = Date" will only generate a new date if the cell is empty. How do I amend the code so that the current date is generated when the workbook opens, regardless of whether or not there is data in the cell?
Bookmarks