View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
westexp[_4_] westexp[_4_] is offline
external usenet poster
 
Posts: 1
Default Convert clunky nested If statement to macro


Just in case this thread comes up in a search, thought I would post what
works. This may not be the most efficient, but it works:

Sub Test2()
Do
If IsEmpty(ActiveCell) Then
If IsEmpty(ActiveCell.Offset(0, -4)) Then
ActiveCell.Value = ""
Else
If ActiveCell.Offset(0, -4) = "Recycle" Then
ActiveCell.Value = ActiveCell.Offset(0, -2) * 7 * 0.25 + 5
Else
ActiveCell.Value = Application.VLookup(ActiveCell.Offset(0, -4),
range("Rates!A1:B5"), 2, False)
End If
End If
End If

ActiveCell.Offset(1, 0).Select

Loop Until IsEmpty(ActiveCell.Offset(0, -4))

End Sub


--
westexp
------------------------------------------------------------------------
westexp's Profile: http://www.excelforum.com/member.php...o&userid=33831
View this thread: http://www.excelforum.com/showthread...hreadid=536084