View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Gary''s Student Gary''s Student is offline
external usenet poster
 
Posts: 11,058
Default Defining a range in vba???? Please help

Sub range_reducer()
Dim r1 As range, r2 As range
Set r1 = range("A1:B200")
Set r2 = Nothing
For Each r In r1
If r.Value 0 Then
If r2 Is Nothing Then
Set r2 = r
Else
Set r2 = Union(r, r2)
End If
End If
Next

MsgBox (r2.Address)
End Sub

Starting with r1, we build r2 to contain only the positives.
--
Gary''s Student
gsnu200711