Excel: Compile error (type mismatch)


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


This question generated 25 answers. To proceed to the answers, click here.

This thread is current as of June 16, 2014.


For more resources for Microsoft Excel