Run-time error 13 - Type mismatch

skyking

Board Regular
Joined
Jul 10, 2010
Messages
52
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
 
Thanks Ogo, You point out what my problem is. I check with cell J72. It is a formula. Unfortunately, it points to an empty cell.

Again, thanks all of you that concern me.

Skyking
 
Upvote 0

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

Forum statistics

Threads
1,224,613
Messages
6,179,901
Members
452,948
Latest member
Dupuhini

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top