Hi,
I'm getting an error 'Application-defined or object-defined error' for the below code.
When debugging, it is goes on the highlighted line, I've used the below code on my other projects and it run okay but I'm now encountering the error now.
Dim x, i As Long, n As Long
Range("J8").Select
With ActiveSheet
x = .Range("J8").CurrentRegion
For i = 2 To UBound(x)
If (Val(Format(x(i, 1), "mm"))) >= 1 And _
(Val(Format(x(i, 1), "mm"))) <= 3 Then
n = n + 1
x(n, 1) = "Q1 2014"
ElseIf (Val(Format(x(i, 1), "mm"))) >= 4 _
And (Val(Format(x(i, 1), "mm"))) <= 6 Then
n = n + 1
x(n, 1) = "Q2 2014"
ElseIf (Val(Format(x(i, 1), "mm"))) >= 7 And _
(Val(Format(x(i, 1), "mm"))) <= 9 Then
n = n + 1
x(n, 1) = "Q3 2014"
ElseIf (Val(Format(x(i, 1), "mm"))) >= 10 And _
(Val(Format(x(i, 1), "mm"))) <= 12 Then
n = n + 1
x(n, 1) = "Q4 2014"
End If
Next i
.Range("AG9").Resize(n, 1).Value = x
End With
Bookmarks