Insert row when value changes, sort the isolated information by date and then by description and sum

Simona

New Member
Joined
Aug 9, 2010
Messages
13
[FONT=&quot]Hello!
I need your help to build a macro that can do this manual and boring task for me.
I have a list of information and I need to:
1 – Insert two rows every time the code in the column A changes
2 – Sort every single new interval by date (column B) and then by description (column D)
3 – Sum the values in every single new interval (column C)
Do you think this is possible or is it asking too much????
Thank you in advance for your help!
Simona

I hope you can understand it from here:
It lost all the formatting though....<o:p></o:p>[/FONT]
[FONT=&quot]Before<o:p></o:p>[/FONT]
<table class="MsoNormalTable" style="width: 395.45pt; border-collapse: collapse;" border="0" cellpadding="0" cellspacing="0" width="527"> <tbody><tr style="height: 15.75pt;"> <td style="width: 38.5pt; padding: 0cm; height: 15.75pt;" width="51">
</td> <td style="width: 69.75pt; padding: 0cm; height: 15.75pt;" width="93">
[FONT=&quot]A<o:p></o:p>[/FONT]​
</td> <td style="width: 81.75pt; padding: 0cm; height: 15.75pt;" width="109">
[FONT=&quot]B<o:p></o:p>[/FONT]​
</td> <td style="width: 67.2pt; padding: 0cm; height: 15.75pt;" width="90">
[FONT=&quot]C<o:p></o:p>[/FONT]​
</td> <td style="width: 138.25pt; padding: 0cm; height: 15.75pt;" width="184">
[FONT=&quot]D<o:p></o:p>[/FONT]​
</td> </tr> <tr style="height: 15pt;"> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]1<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]Analysis Code<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]Transaction Date<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]Base Amount<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]Description<o:p></o:p>[/FONT]​
</td> </tr> <tr style="height: 15pt;"> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]2<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]1011101<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]31/08/2010<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]2,047.50<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]BOULANG<o:p></o:p>[/FONT]​
</td> </tr> <tr style="height: 15pt;"> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]3<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]1011101<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]20/07/2010<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]27.53<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]ANT PATISSERIE<o:p></o:p>[/FONT]​
</td> </tr> <tr style="height: 15pt;"> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]4<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]1011102<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]04/08/2010<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]531.00<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]TANT<o:p></o:p>[/FONT]​
</td> </tr> <tr style="height: 15pt;"> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]5<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]1011102<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]31/07/2010<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]-1,350.48<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]Soft Drink Accrual<o:p></o:p>[/FONT]​
</td> </tr> <tr style="height: 15pt;"> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]6<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]1011102<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]31/08/2010<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]-14,869.60<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]Soft Drinks Stock<o:p></o:p>[/FONT]​
</td> </tr> <tr style="height: 15pt;"> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]7<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]1011201<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]31/08/2010<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]-20,086.75<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]Food Stock<o:p></o:p>[/FONT]​
</td> </tr> <tr style="height: 15pt;"> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]8<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]1011201<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]31/07/2010<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]18,446.90<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]Food Stock<o:p></o:p>[/FONT]​
</td> </tr> <tr style="height: 15pt;"> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]9<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]1011201<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]31/07/2010<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]-2,140.37<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]Food Accrual<o:p></o:p>[/FONT]​
</td> </tr> <tr style="height: 15pt;"> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]10<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]1011202<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]18/08/2010<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]595.80<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]FRESH DISP<o:p></o:p>[/FONT]​
</td> </tr> <tr style="height: 15pt;"> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]11<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]1011202<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]07/08/2010<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]86.59<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]ABC FOOD<o:p></o:p>[/FONT]​
</td> </tr> <tr style="height: 15pt;"> <td style="padding: 0cm; height: 15pt;">
</td> <td style="padding: 0cm; height: 15pt;">
</td> <td style="padding: 0cm; height: 15pt;">
</td> <td style="padding: 0cm; height: 15pt;">
</td> <td style="padding: 0cm; height: 15pt;">
</td> </tr> <tr style="height: 15pt;"> <td style="padding: 0cm; height: 15pt;"> [FONT=&quot]After<o:p></o:p>[/FONT]
</td> <td style="padding: 0cm; height: 15pt;">
</td> <td style="padding: 0cm; height: 15pt;">
</td> <td style="padding: 0cm; height: 15pt;">
</td> <td style="padding: 0cm; height: 15pt;">
</td> </tr> <tr style="height: 15.75pt;"> <td style="padding: 0cm; height: 15.75pt;">
</td> <td style="padding: 0cm; height: 15.75pt;">
[FONT=&quot]A<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15.75pt;">
[FONT=&quot]B<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15.75pt;">
[FONT=&quot]C<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15.75pt;">
[FONT=&quot]D<o:p></o:p>[/FONT]​
</td> </tr> <tr style="height: 15pt;"> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]1<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]Analysis Code<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]Transaction Date<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]Base Amount<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]Description<o:p></o:p>[/FONT]​
</td> </tr> <tr style="height: 15pt;"> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]2<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]1011101<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]20/07/2010<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]27.53<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]ANT PATISSERIE<o:p></o:p>[/FONT]​
</td> </tr> <tr style="height: 15pt;"> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]3<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]1011101<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]31/08/2010<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]2,047.50<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]BOULANG<o:p></o:p>[/FONT]​
</td> </tr> <tr style="height: 15pt;"> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]4<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]sum<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]2,075.03<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
</td> </tr> <tr style="height: 15pt;"> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]5<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
</td> <td style="padding: 0cm; height: 15pt;">
</td> <td style="padding: 0cm; height: 15pt;">
</td> <td style="padding: 0cm; height: 15pt;">
</td> </tr> <tr style="height: 15pt;"> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]6<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]1011102<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]31/07/2010<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]-1,350.48<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]Soft Drink Accrual<o:p></o:p>[/FONT]​
</td> </tr> <tr style="height: 15pt;"> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]7<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]1011102<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]31/08/2010<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]-14,869.60<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]Soft Drinks Stock<o:p></o:p>[/FONT]​
</td> </tr> <tr style="height: 15pt;"> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]8<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]1011102<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]04/08/2010<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]531.00<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]TANT<o:p></o:p>[/FONT]​
</td> </tr> <tr style="height: 15pt;"> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]9<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]sum<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]-15,689.08<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
</td> </tr> <tr style="height: 15pt;"> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]10<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
</td> <td style="padding: 0cm; height: 15pt;">
</td> <td style="padding: 0cm; height: 15pt;">
</td> <td style="padding: 0cm; height: 15pt;">
</td> </tr> <tr style="height: 15pt;"> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]11<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]1011201<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]31/08/2010<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]-20,086.75<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]Food Stock<o:p></o:p>[/FONT]​
</td> </tr> <tr style="height: 15pt;"> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]12<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]1011201<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]31/07/2010<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]18,446.90<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]Food Stock<o:p></o:p>[/FONT]​
</td> </tr> <tr style="height: 15pt;"> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]13<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]1011201<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]31/07/2010<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]-2,140.37<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]Food Accrual<o:p></o:p>[/FONT]​
</td> </tr> <tr style="height: 15pt;"> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]14<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]sum<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]-3,780.22<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
</td> </tr> <tr style="height: 15pt;"> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]15<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
</td> <td style="padding: 0cm; height: 15pt;">
</td> <td style="padding: 0cm; height: 15pt;">
</td> <td style="padding: 0cm; height: 15pt;">
</td> </tr> <tr style="height: 15pt;"> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]16<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]1011202<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]18/08/2010<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]595.80<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]FRESH DISP<o:p></o:p>[/FONT]​
</td> </tr> <tr style="height: 15pt;"> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]17<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]1011202<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]07/08/2010<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]86.59<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]ABC FOOD<o:p></o:p>[/FONT]​
</td> </tr> <tr style="height: 15pt;"> <td style="padding: 0cm; height: 15pt;">
</td> <td style="padding: 0cm; height: 15pt;">
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]sum<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
[FONT=&quot]682.39<o:p></o:p>[/FONT]​
</td> <td style="padding: 0cm; height: 15pt;">
</td> </tr> </tbody></table>
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Simona,

If it wasn't for the extra space between groups you could use Data, Subtotals.

Something like this.


Excel Workbook
ABCD
1Analysis CodeTransaction DateBase AmountDescription
2101110131/08/20102,047.50BOULANG
3101110120/07/201027.53ANT PATISSERIE
41011101 Total2075.03
510111024/8/2010531TANT
6101110231/07/2010-1,350.48Soft Drink Accrual
7101110231/08/2010-14,869.60Soft Drinks Stock
81011102 Total-15,689.08
9101120131/08/2010-20,086.75Food Stock
10101120131/07/201018,446.90Food Stock
11101120131/07/2010-2,140.37Food Accrual
121011201 Total-3,780.22
13101120218/08/2010595.8FRESH DISP
1410112027/8/201086.59ABC FOOD
151011202 Total682.39
16Grand Total-16711.88
17
Sheet1
 
Upvote 0
Simona,

How should the data be sorted?

1. Column A, ascending (for sure).

2. Column B, ascending or descending?

3. Column D, ascending or descending?
 
Upvote 0
Hi, Try this:-
Code:
[COLOR="Navy"]Sub[/COLOR] MG08Sep58
[COLOR="Navy"]Dim[/COLOR] rng [COLOR="Navy"]As[/COLOR] Range
[COLOR="Navy"]Dim[/COLOR] Rw [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
[COLOR="Navy"]Dim[/COLOR] R [COLOR="Navy"]As[/COLOR] Range
[COLOR="Navy"]Set[/COLOR] rng = Range(Range("A2"), Range("A" & Rows.Count).End(xlUp))
   [COLOR="Navy"]For[/COLOR] Rw = rng.Count + 1 To 2 [COLOR="Navy"]Step[/COLOR] -1
    [COLOR="Navy"]With[/COLOR] Range("A" & Rw)
        [COLOR="Navy"]If[/COLOR] Not .Value = .Offset(-1).Value [COLOR="Navy"]Then[/COLOR]
            .Resize(2).EntireRow.Insert
        [COLOR="Navy"]End[/COLOR] If
    [COLOR="Navy"]End[/COLOR] With
[COLOR="Navy"]Next[/COLOR] Rw
[COLOR="Navy"]Set[/COLOR] rng = Range(Range("A2"), Range("A" & Rows.Count).End(xlUp))
[COLOR="Navy"]Set[/COLOR] rng = rng.SpecialCells(xlCellTypeConstants)
[COLOR="Navy"]Dim[/COLOR] tot
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] R [COLOR="Navy"]In[/COLOR] rng.Areas
    R.Resize(, 4).Sort Range(R(1).Offset(, 1).Address), xlAscending
    R(R.Count + 1, 2) = "Sum"
    R(R.Count + 1, 3) = Application.Sum(R.Offset(, 2))
[COLOR="Navy"]Next[/COLOR] R
Range("A2").Resize(2).EntireRow.Delete
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0
Hi hiker95,

thank you for your prompt response.
I've tried this solution, which works fine, but then I need to go in every single new interval and sort it by date and description.

I've just found this code to add the rows every time the code in the column A changes:

Sub AddRows()
Dim LR As Long
Dim Rw As Long

Application.ScreenUpdating = False

LR = Range("A" & Rows.Count).End(xlUp).Row

For Rw = LR - 1 To 2 Step -1
If Range("A" & Rw) <> Range("A" & Rw + 1) Then _
Range("A" & Rw + 1).EntireRow.Insert xlShiftDown
Next Rw
Application.ScreenUpdating = True

End Sub


but I don't know how to add 2 two rows (it's adding just one) and then sort the information by date and by description.
Do you have any idea?
 
Upvote 0
MickG,

Very nice.

Your code example will save me a lot of time and effort in the future.

What a great place for learning.

Thanks again.
 
Upvote 0
Hi hiker95 and MickG,

thank you for your help!!!
The code is working perfectly!

Just a couple of questions:

1) what should I change in the code if I want to sort first by description and then by date??

2) what should I change in the code if I realise that the description is not anymore in the column D but E??

3) how can i get the sum to be always in the same column C. At the moment the code is returning it in the column E!

Thank you :)!
 
Upvote 0
Hi hiker95 and MickG,

thank you for your help!!!
The code is working perfectly!

Just a couple of questions:

1) what should I change in the code if I want to sort first by description and then by date??

ans (1):-
I'm not sure how that works!! My code sorts all 4 columns Based on the Dates column. You could sort the same 4 columns based on the Description Column, but how would you sort on "Description" and then the "Dates" so you could see the results, unless they where sorted individually, then all the related data would be mixed up. !!!!


2) what should I change in the code if I realise that the description is not anymore in the column D but E??

Ans(2):-
If you want to alter the code to relect Column "E" (increase data columns to 5) as the description Column , Change the line as below to "5"
Code:
    R.Resize(, 5).Sort Range(R(1).Offset(, 1).Address), xlAscending

3) how can i get the sum to be always in the same column C. At the moment the code is returning it in the column E!

Ans(3) :-_
I Don't understand how the results end up in column "E", Can you post some data , that this happens with, ??


Thank you :)!
Regards Mick
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,575
Messages
6,125,631
Members
449,241
Latest member
NoniJ

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top