[VBA] Migrated from Excel 2010 to 2016. Type Mismatch error

NessPJ

Active Member
Joined
May 10, 2011
Messages
416
Office Version
  1. 365
Hello all,

Recently i have migrated a lot of systems from Office 2010 to 2016.
All of my reports are working, but one is persistently giving me a Type mismatch error now.
I debugged the code but i really can't detect what is going wrong.

The exact error is: Run-time error '-2147352571 (800200005)': Type mismatch.

Here's the code with the error:
Rich (BB code):
Dim LastRowActiviteit, LastRowTag As String
LastRowTag = ThisWorkbook.Sheets("Masterdata").Range("R101").End(xlUp).Row




Dim Row As Integer


    With Registratie.Tag1
    For Row = 5 To LastRowTag
    .AddItem Sheets("Masterdata").Range("R" & Row)
    Next Row
    End With
    
    With Registratie.Tag2
    For Row = 5 To LastRowTag
    .AddItem Sheets("Masterdata").Range("T" & Row)
    Next Row
    End With

I underlined the segment of the code that the debugger points to.
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Why is lastrowtag defined as string when it is an integer number
 
Upvote 0
That's just awful 'coding' on my end. I never got any training for this so..

I changed it to an integer. The error message still persists though. Any ideas? :)
 
Upvote 0
Dont use the word Row as a variable. What happens then?

I changed the code to the following, but the exact same mismatch still happens:

Code:
Dim LastRowTagMD1 As Integer
Dim LastRowTagMD2 As Integer

LastRowTagMD1 = ThisWorkbook.Sheets("Masterdata").Range("R101").End(xlUp).Row
LastRowTagMD2 = ThisWorkbook.Sheets("Masterdata").Range("T101").End(xlUp).Row

Dim RowMD1 As Integer
Dim RowMD2 As Integer


    With Registratie.Tag1
    For RowMD1 = 5 To LastRowTagMD1
    .AddItem Sheets("Masterdata").Range("R" & RowMD1)
    Next RowMD1
    End With
    
    With Registratie.Tag2
    For RowMD2 = 5 To LastRowTagMD2
    .AddItem Sheets("Masterdata").Range("T" & RowMD2)
    Next RowMD2
    End With
 
Upvote 0
Last edited:
Upvote 0

Forum statistics

Threads
1,214,614
Messages
6,120,517
Members
448,968
Latest member
Ajax40

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