Hi there,
Having an issue updating a file from old 2008 Excel to Excel 2019.
This routine use to work and still does except this one line is getting called with a runtime error 1004. Method '_Default of object 'Range' Failed.
Can anyone suggest a different way to write this line or why it might not work in a newer version go excel?
wsBudget.Range("O78") = iDaysToExpiry
much appreciated
Having an issue updating a file from old 2008 Excel to Excel 2019.
This routine use to work and still does except this one line is getting called with a runtime error 1004. Method '_Default of object 'Range' Failed.
Can anyone suggest a different way to write this line or why it might not work in a newer version go excel?
wsBudget.Range("O78") = iDaysToExpiry
Rich (BB code):
Public Sub CheckExpiry()
Dim oScrambler As New Encryption
Dim wsBudget As Worksheet
Dim sActivationKey As String
Dim dteExpiry As String
Dim iDaysToExpiry As Integer
Dim sExpiryDate As String
Application.EnableCancelKey = xlDisabled
Set wsBudget = ThisWorkbook.Sheets("budget")
sActivationKey = ThisWorkbook.Sheets("Authorise").Range("D10")
'Decrypt will return the date as a number, so convert back to date format
sExpiryDate = oScrambler.Decrypt(sActivationKey)
If sExpiryDate = "" Then
'Invalid code - may have been tampered with
MsgBox "Your activation code is invalid. Please contact for a new activation key.", vbError, g_sSystem
Call HideAll
ThisWorkbook.Sheets("Authorise").Activate
End
Else
dteExpiry = CDate(sExpiryDate)
End If
wsBudget.Unprotect (g_sPassword)
iDaysToExpiry = DateDiff("d", Now(), dteExpiry)
wsBudget.Range("O77") = Format(dteExpiry, "MMMM dd, yyyy")
wsBudget.Range("O78") = iDaysToExpiry
wsBudget.Protect (g_sPassword)
If iDaysToExpiry < 0 Then
'Expired already
MsgBox "Your validation time has expired. Please contact for a new activation key.", vbError, g_sSystem
Call HideAll
ThisWorkbook.Sheets("Authorise").Activate
End
Else
If iDaysToExpiry <= 30 Then
'Expiring within 30 days
MsgBox "Your licence will expire in " & iDaysToExpiry & " days." & vbNewLine & "Please contact soon for a new activation key.", vbExclamation, g_sSystem
End If
Call ShowAll
End If
End Sub
much appreciated
Last edited by a moderator: