Thread: Sumif
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Fabian Fabian is offline
external usenet poster
 
Posts: 21
Default Sumif

Thanks Gary, working perfect.. I will ask you some code related to this in
another post

"Gary Keramidas" wrote:

here's one way you can look at for xl2003

Sub test()
Dim ws As Worksheet
Dim lastrow As Long
Dim i As Long
Dim x As Long
Dim cntr As Long
Dim tempval As Double
Set ws = Worksheets("Sheet1")
lastrow = ws.Cells(Rows.Count, "A").End(xlUp).Row
For i = 2 To lastrow
x = 1
cntr = 0
tempval = 0
Do While cntr < 6
With ws
If x = 256 Then Exit Do
If .Cells(i, x).Value 0 Then
tempval = .Cells(i, x).Value + tempval
Debug.Print .Cells(i, x).Address
cntr = cntr + 1
x = x + 1
Else
x = x + 1
End If
End With
Loop
Debug.Print tempval
Next
End Sub


--

Gary
Excel 2003


"Fabian" wrote in message
...
Hi,

I am loking for a piece of code for the following. I have 100 rows and 39
columns. Every row could be in 3 different ways:
A B C D E F G H
I..............AM
1 0 0 0 100 150 65 85 73
25............89
2 0 0 0 56 130 125 88 178
32...........0
3 98 36 58 89 489 125 88 178
32...........56
I need to sum the first 6 cells with numbers or sales (no with 0's), and
those first 6 numbers for every row could start at any colums of those 39
columns. Example row 1 should sum from D to I, row 2 should sum from D to
I,
row 3 from A to F. I am not sure how to start
Thanks