View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Tom London[_2_] Tom London[_2_] is offline
external usenet poster
 
Posts: 3
Default How do I work on data starting to a cell a cell with a require

Bob

Thanks

The programme appears to be adding the number of occurences in a row of the
0 digit and deducting 1 when I run it. I need to sum all the data to the left
of the 1st (leftmost) 0 in a row and enter that data into column 1.

Thanks again.

Tom

"Bob Phillips" wrote:

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