Dear all,
Can you help to fix the Run-time error for the VBA?
When I step into the VBA code and it pops up a message box at the red line below with "Run-time error 13 - Type mismatch". Can you help?
Private Sub CommandNextMonth_Click()
Dim val As String
Dim LR As Range
Dim a As Range
Dim val2 As Date
Cells(72, "H") = Date 'Set Last Access Day to Current Day
val = Cells(72, "J") 'Set to End Day (Last Month)
Debug.Print val
val2 = CDate(val) 'Change val to calculable
Debug.Print val2
For Each a In Range("A53:A100")
Debug.Print a.Address
Set a = ActiveWorkbook.Sheets(1).Range("A53:A53")
If a = "" Then Exit For
If a.Value < val2 Then
Debug.Print a.Address, a.Value, val2
Application.GoTo a, True
a.EntireRow.Delete xlNone
End If
Next
CommandNextMonth.Enabled = False
CommandPreviousMonth.Enabled = True
Application.Calculate
End Sub
Your early reponse is much appreciate.
Regards,
Wky King
Can you help to fix the Run-time error for the VBA?
When I step into the VBA code and it pops up a message box at the red line below with "Run-time error 13 - Type mismatch". Can you help?
Private Sub CommandNextMonth_Click()
Dim val As String
Dim LR As Range
Dim a As Range
Dim val2 As Date
Cells(72, "H") = Date 'Set Last Access Day to Current Day
val = Cells(72, "J") 'Set to End Day (Last Month)
Debug.Print val
val2 = CDate(val) 'Change val to calculable
Debug.Print val2
For Each a In Range("A53:A100")
Debug.Print a.Address
Set a = ActiveWorkbook.Sheets(1).Range("A53:A53")
If a = "" Then Exit For
If a.Value < val2 Then
Debug.Print a.Address, a.Value, val2
Application.GoTo a, True
a.EntireRow.Delete xlNone
End If
Next
CommandNextMonth.Enabled = False
CommandPreviousMonth.Enabled = True
Application.Calculate
End Sub
Your early reponse is much appreciate.
Regards,
Wky King