Dear All,
I am writing a macro where i have multiple conditions for getting the data and i am stuck here as it is giving only single output that is "0-1 days"... Please help
below is my code :
Lastrow1 = Sheets("Rawdata").Range("A" & Rows.Count).End(xlUp).Row
For A = 2 To Lastrow1
If Cells(A, "D") >= 0 Then
Cells(A, "CK") = "0-1 Days"
ElseIf Cells(A, "D") >= 1 Then
Cells(A, "CK") = "1-3 Days"
ElseIf Cells(A, "D") >= 3 Then
Cells(A, "CK") = "3-5 Days"
ElseIf Cells(A, "D") >= 5 Then
Cells(A, "CK") = "5-10 Days"
ElseIf Cells(A, "D") >= 10 Then
Cells(A, "CK") = "10-20 Days"
ElseIf Cells(A, "D") >= 20 Then
Cells(A, "CK") = "20-30 Days"
ElseIf Cells(A, "D") >= 30 Then
Cells(A, "CK") = "30-40 Days"
ElseIf Cells(A, "D") >= 45 Then
Cells(A, "CK") = "45-60 Days"
ElseIf Cells(A, "D") >= 60 Then
Cells(A, "CK") = "60-90 Days"
ElseIf Cells(A, "D") >= 90 Then
Cells(A, "CK") = "90+ Days"
Else: Cells(A, "D") = "overdue"
End If
Next
End With
End Sub
I am writing a macro where i have multiple conditions for getting the data and i am stuck here as it is giving only single output that is "0-1 days"... Please help
below is my code :
Lastrow1 = Sheets("Rawdata").Range("A" & Rows.Count).End(xlUp).Row
For A = 2 To Lastrow1
If Cells(A, "D") >= 0 Then
Cells(A, "CK") = "0-1 Days"
ElseIf Cells(A, "D") >= 1 Then
Cells(A, "CK") = "1-3 Days"
ElseIf Cells(A, "D") >= 3 Then
Cells(A, "CK") = "3-5 Days"
ElseIf Cells(A, "D") >= 5 Then
Cells(A, "CK") = "5-10 Days"
ElseIf Cells(A, "D") >= 10 Then
Cells(A, "CK") = "10-20 Days"
ElseIf Cells(A, "D") >= 20 Then
Cells(A, "CK") = "20-30 Days"
ElseIf Cells(A, "D") >= 30 Then
Cells(A, "CK") = "30-40 Days"
ElseIf Cells(A, "D") >= 45 Then
Cells(A, "CK") = "45-60 Days"
ElseIf Cells(A, "D") >= 60 Then
Cells(A, "CK") = "60-90 Days"
ElseIf Cells(A, "D") >= 90 Then
Cells(A, "CK") = "90+ Days"
Else: Cells(A, "D") = "overdue"
End If
Next
End With
End Sub