Compile error (type mismatch)

beginner999

New Member
Joined
Jun 16, 2014
Messages
33
Hi Guys!
I'm using the looping condition for extraction of years. And heres my code. I having a trouble when i run it. Suggestion or clarification please. Thankss!

Sub GetLoans()

Dim i As String
Dim strYrFlag As String

Range("E1").Select
For i = 1 To 4876
Range("H1:J1") As Range

If Range("D1").Value = ("IN DMFAS") Then
Cells(i, 1).Value = Range("H1:J1").Value < 20100000
strYrFlag = "2009Below"
ElseIf Range("D1").Value = ("NOT IN IEDMS") Then
Cells(i, 1).Value = Range("H1:J1").Value < 20100000
strYrFlag = "2009Below"
ElseIf Range("D1").Value = ("IN DMFAS") Then
Cells(i, 1).Value = Range("H1:J1").Value >= 20101231
strYrFlag = "Jan-Dec2010"
ElseIf Range("D1").Value = ("NOT IN IEDMS") Then
Cells(i, 1).Value = Range("H1:J1").Value >= 20101231
strYrFlag = "Jan-Dec2010"
ElseIf Range("D1").Value = ("IN DMFAS") Then
Cells(i, 1).Value = Range("H1:J1").Value >= 20111231
strYrFlag = "Jan-Dec2011"
ElseIf Range("D1").Value = ("NOT IN IEDMS") Then
Cells(i, 1).Value = Range("H1:J1").Value >= 20111231
strYrFlag = "Jan-Dec2011"
ElseIf Range("D1").Value = ("IN DMFAS") Then
Cells(i, 1).Value = Range("H1:J1").Value >= 20121231
strYrFlag = "Jan-Dec2012"
ElseIf Range("D1").Value = ("NOT IN IEDMS") Then
Cells(i, 1).Value = Range("H1:J1").Value >= 20121231
strYrFlag = "Jan-Dec2012"
ElseIf Range("D1").Value = ("IN DMFAS") Then
Cells(i, 1).Value = Range("H1:J1").Value >= 20131231
strYrFlag = "Jan-Dec2013"
ElseIf Range("D1").Value = ("NOT IN IEDMS") Then
Cells(i, 1).Value = Range("H1:J1").Value >= 20131231
strYrFlag = "Jan-Dec2013"
ElseIf Range("D1").Value = ("IN DMFAS") Then
Cells(i, 1).Value = Range("H1:J1").Value >= 20141231
strYrFlag = "Jan-Dec2014"
ElseIf Range("D1").Value = ("NOT IN IEDMS") Then
Cells(i, 1).Value = Range("H1:J1").Value >= 20141231
strYrFlag = "Jan-Dec2014"
ElseIf Range("D1").Value = ("IN DMFAS") Then
Cells(i, 1).Value = Range("H1:J1").Value >= 20151231
strYrFlag = "Jan-Dec2015"
ElseIf Range("D1").Value = ("NOT IN IEDMS") Then
Cells(i, 1).Value = Range("H1:J1").Value >= 20151231
strYrFlag = "Jan-Dec2015"
ElseIf Range("D1").Value = ("IN DMFAS") Then
Cells(i, 1).Value = Range("H1:J1").Value >= 20161231
strYrFlag = "Jan-Dec2016"
ElseIf Range("D1").Value = ("NOT IN IEDMS") Then
Cells(i, 1).Value = Range("H1:J1").Value >= 20161231
strYrFlag = "Jan-Dec2016"

End If
Next i
 
Last edited:
Yes sir its working. But how can i include this formula to your formula?

(IF(OR(D1="IN DMFAS",D1="NOT IN IEDMS")

Thanks sir! :) By the way, Goodmorning!
 
Upvote 0

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Based on the examples you've provided, I don't think you need this sort of test: (IF(OR(D1="IN DMFAS",D1="NOT IN IEDMS")

If my formula works, why change it?

Or if it doesn't work, give me some examples so we can change it.
 
Upvote 0
Sir, another question.

When i run the file Run-time error appears.

"In the current file format a worksheet cannot more than 65472 array formula that refers to another worksheet."

Can you explain me what is this about? Is it about the formula you gave? Thanks.
 
Last edited:
Upvote 0
This is a totally different problem.

In Excel 2013 and earlier versions, you can't have more than 65,472 array formulas (i.e. the curly-bracket {} formulas that you enter with CTRL-SHIFT-ENTER) referring to another sheet.

If you need help you should start a new thread, because no-one is going to read all the way down to here to answer a new question.
 
Upvote 0

Forum statistics

Threads
1,216,075
Messages
6,128,657
Members
449,462
Latest member
Chislobog

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