Run-Time error '13' Type Mismatch

mdeni0528

New Member
Joined
Aug 11, 2021
Messages
16
Office Version
  1. 2010
Platform
  1. Windows
Hello,

I am receiving a run-time error 13 type mismatch for the code below. The error started when I saved the file with a new name and cleared out the names found in column A (names were in A9:A278). I would like to share my workbook with another organization and removed data to provide a blank template.

VBA Code:
sub auto_open()
Dim i As Long, j As Long
Dim sh As Worksheet

Application.ScreenUpdating = False
For Each sh In Sheets
sh.Unprotect "Test"
For i = 9 To sh.Range("A" & Rows.Count).End(3).Row
For j = 3 To sh.Cells(i, Columns.Count).End(1).Column Step 2
If Date > sh.Cells(i, j).Value Then
sh.Cells(i, j - 1).Resize(1, 2).Value = ""
End If
Next
Next
sh.Protect "Test", DrawingObjects:=True, Contents:=True, Scenarios:=True, AllowFiltering:=True
Next
End Sub

Line Error:
If Date > sh.Cells(i, j).Value Then
 

Attachments

  • Worksheet Example.JPG
    Worksheet Example.JPG
    196.5 KB · Views: 15

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
What's the value of sh.Cells(i, j) when you get the error?

Is it an error perhaps, e.g. #N/A?
 
Upvote 0

Forum statistics

Threads
1,215,039
Messages
6,122,799
Members
449,095
Latest member
m_smith_solihull

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