arnab0711
01-26-2011, 04:36 AM
hi,
I want do a macro which will do somewhat like this -
1)The macro will lookup for a number in column "N"
2)In result will be in column "AR"
3)The logic will be if the number is >180 it will ">180"
if the # is >90 it will show "90 - 180"
if the # is >60 it will show "60-90"
if the # is >30 it will show "30-60"
if the # is <30 it will show "<30"
I have written the code as
Sub logic()
Dim i As Long
For i = 2 To Range("AR" & Rows.Count).End(xlUp).Row
Select Case Range("AQ" & i).Value
Case Is > 180
Range("AR" & i).Value = "> 180"
Case Is >= 90
Range("AR" & i).Value = "90 - 180"
Case Is >= 60
Range("AR" & i).Value = "60 - 90"
Case Is >= 30
Range("AR" & i).Value = "30-60"
Case Is >= 0
Range("AR" & i).Value = "< 30"
Case Else
' Don't change anything
End Select
Next i
End Sub
I want do a macro which will do somewhat like this -
1)The macro will lookup for a number in column "N"
2)In result will be in column "AR"
3)The logic will be if the number is >180 it will ">180"
if the # is >90 it will show "90 - 180"
if the # is >60 it will show "60-90"
if the # is >30 it will show "30-60"
if the # is <30 it will show "<30"
I have written the code as
Sub logic()
Dim i As Long
For i = 2 To Range("AR" & Rows.Count).End(xlUp).Row
Select Case Range("AQ" & i).Value
Case Is > 180
Range("AR" & i).Value = "> 180"
Case Is >= 90
Range("AR" & i).Value = "90 - 180"
Case Is >= 60
Range("AR" & i).Value = "60 - 90"
Case Is >= 30
Range("AR" & i).Value = "30-60"
Case Is >= 0
Range("AR" & i).Value = "< 30"
Case Else
' Don't change anything
End Select
Next i
End Sub