Thread: Select Range
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
GS[_5_] GS[_5_] is offline
external usenet poster
 
Posts: 226
Default Select Range

Per Jessen explained :
This should do it:

Sub Test()

Cells(2, 4) = 0
For i = 1 To 1000
If InStr(1, Cells(i, 1), "SAFEWAY", vbTextCompare) Then
Cells(2, 4) = Cells(2, 4) - Cells(i, 2)
End If
Next i
End Sub

Regards,
Per


Another way:

Sub Test()
Dim i As Integer
Cells(2, 4) = 0
For i = 1 To 1000
If (InStr(Cells(i, 1), "SAFEWAY") 0) Then _
Cells(2, 4) = Cells(2, 4) - Cells(i, 2)
Next i
End Sub

regards,

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc