Type mismatch (Error 13)

helplessnoobatexcel

New Member
Joined
Dec 15, 2023
Messages
45
Office Version
  1. 365
Platform
  1. Windows
1702974419038.png

Hi All, I have this error in my code Type Mismatch (Error 13) that I am unable to rectify. Any idea on how I can do so? Btw I moused over the error during debugging and found my UserRow to be "".
 
This means that your formula is hitting the IFERROR part and returning ""

You need to look at why your match is not working. I guess that UserName is a named range, maybe it does not contain a match to B9.
Ahh I see. I'm checking my excel sheet and there doesn't seem to be an error though as it is correctly displaying the numerical value so I'm unsure why it's displaying "" in the vba code. Any possible suggestions on how to fix this?
 
Upvote 0

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
I see .'Range("B12").Value = "". Does this mean that it isn't registering anything in my User Row?

You cannot assign a null value to a long variant. That's the issue.

Ahh I see. I'm checking my excel sheet and there doesn't seem to be an error though as it is correctly displaying the numerical value so I'm unsure why it's displaying "" in the vba code. Any possible suggestions on how to fix this?

Make sure the code name of the sheet you're referencing is Sheet11 as per the first line of your code.
 
Upvote 0
Amend your formula to, and see what it returns:
Excel Formula:
=MATCH(B9,UserName,0)+4

Also check that the named range 'UserName' covers all of the cells that you think it should. If your spreadsheet displayed a numeric value in your result cell (B12) then VBA will pick it up.

Is the formula you displayed in cell B12?
 
Upvote 0
You cannot assign a null value to a long variant. That's the issue.
Ahh I see. May I know how I can possibly rectify this? Also I realised this issue can be fixed as it is caused by no details being entered into the login form which returns an N/A value. However I have encountered another error of
1702977413829.png

when I continue running the code... This is the error line:
1702977463220.png

it displays SheetNm = "Admin" when I moused over it.
Sorry for asking so many questions, I'm relatively new to vba macro ;-;
 
Upvote 0
Amend your formula to, and see what it returns:
Excel Formula:
=MATCH(B9,UserName,0)+4

Also check that the named range 'UserName' covers all of the cells that you think it should. If your spreadsheet displayed a numeric value in your result cell (B12) then VBA will pick it up.

Is the formula you displayed in cell B12?
Ahh I see, I have tried your method and it returns me the value that I want. Cool, thanks! Yep, the formula is displayed in cell B12. However I now have another new error... ;-;
 
Upvote 0
Do you have a sheet in the workbook with the name that resides in the cell: '.Cells(4,SheetCol).Value'?
 
Upvote 0
Row 4 and columns 6 to 16 would need to have the names of sheets that exist in the workbook.
 
Upvote 0
Are they EXACT?

The error suggests that the VBA can't find a sheet that is stored in 'SheetNm' at the time of the error. Hover over 'SheetNm' when you get the error and see what it is.
 
Upvote 0
Solution

Forum statistics

Threads
1,215,069
Messages
6,122,954
Members
449,095
Latest member
nmaske

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