Run Time Error 13

xcelnovice

Board Regular
Joined
Dec 31, 2011
Messages
81
Hi, I inherited a macro & it has worked in previous months but this month I am getting the data type mismatch error. I've done some digging & understand that is telling me its an unrecognized data type but I wanted to post the code to see if anyone sees somenthin obvious...theres a ton more code to this macro so I doubt it will be solvable but it was worth a shot...

Sub Step_2()</SPAN>

Dim JEMonth As Byte</SPAN>
Dim JEYear As Integer</SPAN>

JEMonth = Sheets("MGR Data").Cells(2, 2).Value 'This is highlighted in yellow & where I get the error'</SPAN></SPAN>
JEYear = Sheets("MGR Data").Cells(2, 1).Value</SPAN>

Dim dtmDate As Date</SPAN>
Dim JEDate As Date</SPAN>
dtmDate = JEMonth & "/1/" & JEYear</SPAN>

JEDate = DateSerial(Year(dtmDate), _</SPAN>
Month(dtmDate) + 1, 0)</SPAN>
UserForm1.JD.Value = JEDate</SPAN>

UserForm1.Show</SPAN>

End Sub


& to see if i understand what I am seeing...first to lines declare variable. 2nd 2 lines are saying the variables are the MGR Data sheet w/ in the workbook, from A1 go down 2 cells & Over 2 cells & return that value (which is 7000-01)

And any code after this is a mystery to me at this point...Thanks</SPAN>
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Well...I don't know what you're trying to get out of that but I assume it's the "01"?

Code:
[COLOR=#333333]Dim JEMonth As Variant[/COLOR]
[COLOR=#333333]Dim JEYear As Integer[/COLOR]

[B]JEMonth = right(Sheets("MGR Data").Cells(2, 2).Value,2) 'This is highlighted in yellow & where I get the error' [/B]
 
Upvote 0
Great thank you! & i figured this would be a challenge. It did get me past that line of code...Am I correct in assuming that if I change the Value,2 to Value,7 it would return the entire #. Thanks so much for the help!
 
Upvote 0
If you want to return the entire number you don't need the LEFT function at all. But, that will cause an error with this line of code:

Code:
[COLOR=#333333]dtmDate = JEMonth & "/1/" & JEYear[/COLOR]

Because 7000-01/1/2014 is not a valid date. And you have dtmDate as Date format.
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,912
Members
452,366
Latest member
TePunaBloke

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