View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
ramse[_7_] ramse[_7_] is offline
external usenet poster
 
Posts: 1
Default subtotal with vba(urgent)


Hi Cliff,

Intially Thanks for code.

Hey cliff you know what is meaning of forum it means sharing of
knowldge. ok. If somebody is in trouble we have to share knowledge,
better not give the lectures and unnecessary advices, better learn how
to help others otherwise keep quite . If u don't want to share better
out from the forum.

I'm very busy with my other tasks thats why i posted my question.time
doen't permit me to do this.ok.

But it doesn't work for me. Its static . I'm able to solve my problem.

If you want you can use for yourself also.

Sub ff()

Dim i, j As Long
Dim startrw As Long
Dim erow As Integer

i = 3
j = 2
startrw = 2

Do While Cells(j, 1) < ""
erow = erow + 1
j = j + 1
Loop

Do While Cells(i - 1, 1) < ""
If Cells(i - 1, 1).Value < Cells(i, 1).Value Then
If Cells(erow + 3, 2) < "" Then
erow = erow + 2
End If
Range(Cells(erow + 3, 2), Cells(erow + 3, 4)).Formula =
"=Sum(b" & startrw & _
":b" & i - 1 & ")"
startrw = i
End If
i = i + 1
Loop

End Sub


Thanks,
Ramse.
Cliff Carson Wrote:
Ramana,
You seem desperate and maybe I'm feeling foolish today so I'm giving
you the
code. If this is part of an independent learning experience or you are
a
student, then I've done a good deed. However if you have a job and
need
this to please your boss then I feel I've done you a disservice. You
should
really tell your boss that you don't know how to solve the problem and
that
he should anticipate "urgent" situations better and either provide
more
training for you or find someone else with the right skills. There's
no use
in setting false expectations.

My solution assumes your data matrix starts at the upper left cell and
is
terminated by a blank row. Also, I think your solution of trying to
stick
formulas into the worksheet was the wrong approach. Hopefully you'll
be
able to understand this code sufficiently to see that I took a
different
approach.



--
ramse
------------------------------------------------------------------------
ramse's Profile: http://www.excelforum.com/member.php...o&userid=31544
View this thread: http://www.excelforum.com/showthread...hreadid=512404