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


Tom, thanks for your response. In my attempt to fit your solution to
the range that has data, I get a "Sub or Function not defined" error at
Vlookup. Any help is much appreciated. It will probably make you
laugh, but this is what I have so far on my test macro:

Sub Test()
Dim srcerange As range
Dim range As range
Dim tons As range

Set srcerange = range("F2").End(xlDown)
Set range = srcerange.Offset(0, 4)
Set tons = srcerange.Offset(0, 2)

For Each cell In range
If srcerange = "Recycle" Then
range = tons.Value * 7 * 0.25 + 5
Else
res = VLookup(range, Worksheets("Rates").range("A1:B5"), 2, False)
If IsError(res) Then
range = "???"
Else
range = res
End If
End If

Next cell

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