View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Unger Dave Unger is offline
external usenet poster
 
Posts: 153
Default Range passed to a function - trying to just move through the range

John,
Change your code as shown, then you'll see why it's not working. You're not stepping thru each cell, you're selecting an offset to the whole range. Hope this helps,

regards,

Dave

Function WAR(Sel As Range) As Double
Y = Sel.Rows.Count

For i = 0 To (Y - 1)
Sel.Offset(i, 0).Select
Sel.Offset(i, 1).Select
Sel.Offset(i, 2).Select

' A = Sel.Offset(i, 0).Value
' B = Sel.Offset(i, 1).Value
' C = Sel.Offset(i, 2).Value
' Use values...

Next i
End Function
But this is not working. Can I not use Offset(x,y) to move around within the range Sel? If

not, now do I reference values at a given x,y coordinate within the range? Thanks.



John Black