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


Hi Dawson,

Thanks for your immediate reply. I have tried my level best. I'm able
to do total sum but i need to brake like below what i mentioned. here
i'm giving my coding i'm not sure where i'm doing wrong. pls help
meout.

Sub summary()
Dim srow As Integer
Dim erow As Integer
Dim STYPE As String
Dim STVALUE As String
Dim LROW As Integer
Dim nrow As Integer
Dim LCONTINUE As Boolean


LROW = 0
nrow = 1
Range("a2").Select
LCONTINUE = True

Do Until Selection.Value = ""
Selection.Offset(1, 0).Select
Loop
endrow = Selection.Row - 1
LROW = LROW + 1
nrow = nrow + 1


STYPE = "A2"
STVALUE = "A" & CStr(LROW)


For lcount = 1 To endrow
'While LCONTINUE = True
If Range(STYPE).Value < Range(STVALUE).Value Then
Range("b" & endrow + 2).Formula = "=SUM(b2:b" & endrow & ")"
Range("b" & endrow + 2 & ":C" & endrow + 2).FillRight
STYPE = "A" & CStr(nrow)
End If
'Wend
Next lcount
End Sub

your help is greatly appreciated.

Thanks,
Ramana.


Ramse,
I could answer your question but I choose not to. You really need to
read
something about VBA rather than hoping that someone will write code for
you.
The best use of a newsgroup is to pose specific questions about
subjects you
know something about after you've made a best effort to solve the
problem
for yourself.

D

"ramse" wrote in
message ...

Hi,

I'm new to vb. pls help me out from this problem.

data in excel like this.
sttype hr1 hr2
------ -- ---
S7 10 20
S7 30 30
S14 40 30
S14 20 50

OUTPUT. in the last row looks like this.
S7 40 50
S14 60 80.

I've need output in the last row like above no of row are not fixed

..

your help is greatly appreciated.

Thanks,
ramse.


--
ramse

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

http://www.excelforum.com/showthread...hreadid=512404



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