Hi All,
Apologies, before I start as this question may seem convoluted.
Background
I have a macro called Z_Consolidate_Monthly_Expenses which basically does the following:-
What I would like to happen for sheet called Monthly Cash Debits is to have it sorted from Row 4 Columns A to H (Columns E to G are hidden) to the last row that has data in it.
Rows 1 to 3 are headings and E3 is a Total of all the items on the Sheet.
I created a macro to sort and it came up with:-
Please note that I have inserted the reference to & LastRow as the existing macro determines the lastrow. Please note the Sheet has set Filters set on in all columns.
Once sorted, on change of data in Column H, I would like to have a Totals Line inserted in a new row with the Cell in Column A set to “Totals for Category nnnn“ where nnnn is the description from column H and the totals of all items that belong to the first Cost Classification in the same row in column E.
The above process of inserting a Totals Line should continue until there are no more.
The new total rows should be formatted as font Candara, 14, Bolded and in RED.
I attach and example of what the sheets looks like at the moment (called Monthly Cash Debits) and what I would like it to look like once the macro has been amended to achieve the above (called Amend Monthly Cash Debits). Please note I have added Column name in both example to aid people looking at this.
I have not include the macros mention above in this post, however if anyone needs to see them please let me know and I will post them.
I hope that the above makes sense.
I will be grateful for any assistance offered.
Apologies, before I start as this question may seem convoluted.
Background
I have a macro called Z_Consolidate_Monthly_Expenses which basically does the following:-
- Creates headers for columns, formats them;
- Extracts Expenses sheets from 5 worksheets;
- Saves the sheet as Monthly Cash Debits
- Copies Monthly Cash Debits and renames it to Monthly Non Cash Debits
- Calls a macro called G_Format_Monthly_Cash_Debits
This macro Applies a Filter to find NON BLANKS in Column D (i.e AutoFilter Field:=4) and then using the LastRow deletes data that is not required and finally sets the Print range.
On return to Z_Consolidate_Monthly_Expenses, it calls a macro called H_Format_Monthly_Non_Cash_Debits and does basically the same as G_Format_Monthly_Cash_Debits but the Filter look for BLANKS in Column D (i.e AutoFilter Field:=4
On return to Z_Consolidate_Monthly_Expenses, it protects sheets and ends the process.
What I would like to happen for sheet called Monthly Cash Debits is to have it sorted from Row 4 Columns A to H (Columns E to G are hidden) to the last row that has data in it.
Rows 1 to 3 are headings and E3 is a Total of all the items on the Sheet.
I created a macro to sort and it came up with:-
VBA Code:
Range("A4:H" & LastRow).Select
ActiveWorkbook.Worksheets("Monthly Cash Debits").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Monthly Cash Debits").Sort.SortFields.Add Key:= _
Range("H4:H" & LastRow), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("Monthly Cash Debits").Sort.SortFields.Add Key:= _
Range("D4:D" & LastRow), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Monthly Cash Debits").Sort
.SetRange Range("A4:H" & LastRow)
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Please note that I have inserted the reference to & LastRow as the existing macro determines the lastrow. Please note the Sheet has set Filters set on in all columns.
Once sorted, on change of data in Column H, I would like to have a Totals Line inserted in a new row with the Cell in Column A set to “Totals for Category nnnn“ where nnnn is the description from column H and the totals of all items that belong to the first Cost Classification in the same row in column E.
The above process of inserting a Totals Line should continue until there are no more.
The new total rows should be formatted as font Candara, 14, Bolded and in RED.
I attach and example of what the sheets looks like at the moment (called Monthly Cash Debits) and what I would like it to look like once the macro has been amended to achieve the above (called Amend Monthly Cash Debits). Please note I have added Column name in both example to aid people looking at this.
I have not include the macros mention above in this post, however if anyone needs to see them please let me know and I will post them.
I hope that the above makes sense.
I will be grateful for any assistance offered.