View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default How do I work on data starting to a cell a cell with a required va

I am reading this slightly differently to Gary

Sub SumCells()
Const thisRow As Long = 10 '<=== change to suit
Dim iLastCol As Long
Dim nSum As Double
Dim i As Long

iLastCol = Cells(thisRow, Columns.Count).End(xlToLeft).Column
For i = 2 To iLastCol
If Cells(thisRow, i).Value = 0 And _
Cells(thisRow, i).Value < "" Then
nSum = nSum + Cells(thisRow, i - 1).Value
End If
Next i

MsgBox nSum
End Sub


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Tom London" <Tom wrote in message
...
I have a workbook full of data. I want to sum the data to the left of

cells
containing 0. The 0 occurs randomly. Any solutions appreciated but am
learning VBA at the moment and would particularly appreciate a VBA

solution.

Thanks