Run Time Error 13: Type Mismatch


Board Regular
Oct 17, 2016
Hi, I am receiving a "Run Time Error 13: Type Mismatch" with the following code. Any thoughts? I cant figure out what to do.

On this line:
Ins = Sh.Cells(n, "A").Value

Sub InsertRows()
Dim End_Row As Long, n As Long, Ins As Long
Dim Sh As Worksheet
For Each Sh In ActiveWorkbook.Sheets
    If Left(Sh.Name, 9) = "Labor BOE" Then
        End_Row = Sh.Range("L" & Rows.Count).End(xlUp).Row
        Application.ScreenUpdating = False
        For n = End_Row To 3 Step -1
          [U][I][B]  Ins = Sh.Cells(n, "A").Value[/B][/I][/U]
            If Ins > 0 Then
                Sh.Range("A" & n + 1 & ":A" & n + Ins).EntireRow.Insert
                Sh.Range("C" & n & ":L" & n).Copy Destination:=Sh.Range("C" & n + 1 & ":L" & n + Ins)
            End If
        Next n
    End If
Next Sh
MsgBox "BOE Generation Complete"
End Sub


MrExcel MVP
Jan 15, 2007
I would guess that some cell contains a text value. Since Ins is dimensioned as Long, it would require a numeric value in that cell. You could either declare Ins as Variant, or use code like this to coerse the value into a Data type Long

Ins = Int(Val(Cstr(Sh.Cells(n, "A").Value)))

Forum statistics

Latest member

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...