LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default subtotal with vba(urgent)


Hi cliff,

thanks a lot for your response. I'm not a VB guy. basically i'm Oracle
guy. suddenly I've need to write a macro for some data which taking
data from my procedure. so I'm trying to do this task . I dont have a
time to go thru this is very urgent so that is why i posted into the
site.

I've tried diffrent types .I'm not sure about vb features thats making
me tought to write the code.

I hope you can understand. tx a lot for ur suggestions. I will do it
what every u mentioned.

if possible pls helpme out.

thanks,
Ramana.

Cliff Carson Wrote:
Ramana,
It's hard for me to read your code - maybe it's because there are so
many
ways to do a thing in VBA and I'm a spoiled C programmer who likes C
because
it is a compact language that doesn't provide so many choices. In
other
words, I think I would do things very differently using a smaller set
of
things I know about VBA. Notwithstanding, here are a few things you
need to
look at:
- What's the purpose of the LROW variable? You set it to 0 then you
increment it once. It is essentially an integer constant with a value
of 1.
It seems as if you had something else in mind for this variable.
- Same question for nrow. It is essentially an integer constant of 2.
It
seems as if you must have intended for these variables to be modified
within
some loop.
- What's going on in your "for loop" when you set Formula and
FillRight?
These operations end up always being applied to the same cells because
nothing in those expressions changes as the loop increments.
- Same question for STYPE in your loop - it is a "loop invariant"
meaning
its value never changes so why do you have this statement inside the
loop?

In summary, I'm much more convinced than before that you should be
learning
VBA through a good book rather than trying to solve an "urgent"
problem
right now.

D

"ramse" wrote in
message ...

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



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



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Subtotal To Include Item Description On Subtotal Line Tickfarmer Excel Discussion (Misc queries) 2 February 23rd 10 07:56 PM
IME MODE FOR EXCEL 2007 (URGENT URGENT) Stella Wong Excel Discussion (Misc queries) 1 August 23rd 08 11:16 PM
pasting to subtotal lines without replacing hidden -non-subtotal l harleydiva67 Excel Discussion (Misc queries) 1 October 12th 06 06:02 PM
Subtotal of Subtotal displays Grand Total in wrong row Thomas Born Excel Worksheet Functions 5 January 6th 05 01:46 PM
Sort, Subtotal, Label Subtotal, Insert row Teak Excel Programming 2 April 8th 04 04:14 PM


All times are GMT +1. The time now is 03:35 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"