Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default need a variation in VBA for subtotals

Hi all
I am very new to VBA and don't see a site for Excel VBA beginners. Thats
why I am posting here.
Hope you can help me.

Below in an example

I recieve a word document weekly and cut and paste the following in an excel
spreadsheet. It is pasted into the same Columns headings and always starts
in the same place G3. Only the number of rows may change with the qty of
info

I can't change the format of the speadsheet , I need to key in other infor
and then pass it along

I have to manually click the sum function in the J column where the xxx are
to find the toal parts used for the week

Info is always already sorted alphabetically by part no. The subtotals
function only puts the totals above or below the information. What I need
is a sum or subtotal in Col J - tot qty , where the xxxx are, in the Last
cell before the part number changes. Is this possible to do with VBA

Any help will be appriciated - Thanks


col G H I J
Part No date qty used tot qty inv no inv
date
---------- ----- ---------- --------- -------
------------
A321 5/1 20
A321 5/3 54 xxx
S589 5/1 52
S589 5/2 19
S589 5/3 16 xxx
X568 5/3 9 xxx






  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default need a variation in VBA for subtotals

Sub Test()
Dim iLastRow As Long
Dim iTotal As Long
Dim i As Long

iLastRow = Cells(Rows.Count, "G").End(xlUp).Row
iTotal = iLastRow
For i = iLastRow To 2 Step -1
If Cells(i, "G").Value < Cells(i - 1, "G").Value Then
Rows(iTotal + 1).Insert
Cells(iTotal + 1, "J").Formula = _
"=SUMIF(J" & i & ":J" & iTotal & _
",""xxx"",I" & i & ":I" & iTotal & ")"
iTotal = i - 1
End If
Next i

End Sub



--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"CJ" wrote in message
...
Hi all
I am very new to VBA and don't see a site for Excel VBA beginners. Thats
why I am posting here.
Hope you can help me.

Below in an example

I recieve a word document weekly and cut and paste the following in an

excel
spreadsheet. It is pasted into the same Columns headings and always starts
in the same place G3. Only the number of rows may change with the qty of
info

I can't change the format of the speadsheet , I need to key in other infor
and then pass it along

I have to manually click the sum function in the J column where the xxx

are
to find the toal parts used for the week

Info is always already sorted alphabetically by part no. The subtotals
function only puts the totals above or below the information. What I need
is a sum or subtotal in Col J - tot qty , where the xxxx are, in the Last
cell before the part number changes. Is this possible to do with VBA

Any help will be appriciated - Thanks


col G H I J
Part No date qty used tot qty inv no

inv
date
---------- ----- ---------- --------- -------
------------
A321 5/1 20
A321 5/3 54 xxx
S589 5/1 52
S589 5/2 19
S589 5/3 16 xxx
X568 5/3 9 xxx








Reply
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
Sumproduct with variation Qikslvr Excel Discussion (Misc queries) 1 February 23rd 10 11:30 PM
Variation on If Then Else Theme DubboPete Excel Discussion (Misc queries) 2 April 17th 09 03:17 AM
Variation from the mean? Greenwich_Man Charts and Charting in Excel 1 September 25th 07 03:14 PM
SUMIF variation? Bob Newman Excel Worksheet Functions 8 June 18th 06 09:13 PM
variation on countif? Liz G Excel Worksheet Functions 2 November 1st 04 07:34 PM


All times are GMT +1. The time now is 07:36 AM.

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

About Us

"It's about Microsoft Excel"