Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Grouping like transactions
Good afternoon
I am working with an excel workbook that lists 100+ transactions. I have managed to write a macro that looks at the transactions row by row, assessing two criteria (column B, and column D), and leaving a few blank lines between the different rows if either column B or Column D are different to the transaction above. However, there are transactions at various points throughout the workbook that have matching criteria in terms of Column B and D. Is there a macro, or could someone help me write a macro, that will look through the entire workbook, find all transactions that have matching values in terms of Column B and D, and group those transactions together? In other words, a method to sort the rows in terms of values in Column B and D? (btw, in case it matters, column B and column D are both text fields) I really would appreciate any advise or suggestions Thanks in anticipation Regards |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Grouping like transactions
Hi
Try this: Sub AAA() Dim LastRow As Long Dim SortRange As Range LastRow = Range("A" & Rows.Count).End(xlUp).Row Set SortRange = Range("A1:F" & LastRow) ' Change column reference as needed SortRange.Sort Key1:=Range("B2"), Order1:=xlAscending, Key2:=Range ("D2") _ , Order2:=xlAscending, Header:=xlYes, OrderCustom:=1, MatchCase:= _ False, Orientation:=xlTopToBottom For r = LastRow To 3 Step -1 If Cells(r, 2) < Cells(r - 1, 2) Or Cells(r, 4) < Cells(r - 1, 4) Then Rows(r).EntireRow.Insert End If Next End Sub Regards, Per On 4 Aug., 16:25, PVANS wrote: Good afternoon I am working with an excel workbook that lists 100+ transactions. *I have managed to write a macro that looks at the transactions row by row, assessing two criteria (column B, and column D), and leaving a few blank lines between the different rows if either column B or Column D are different to the transaction above. * However, there are transactions at various points throughout the workbook that have matching criteria in terms of Column B and D. *Is there a macro, or could someone help me write a macro, that will look through the entire workbook, find all transactions that have matching values in terms of Column B and D, and group those transactions together? *In other words, a method to sort the rows in terms of values in Column B and D? (btw, in case it matters, column B and column D are both text fields) I really would appreciate any advise or suggestions Thanks in anticipation Regards |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Last few transactions | Excel Worksheet Functions | |||
Grouping daily transactions in a pivot table by month - CANNOT GROUPTHAT SELECTION ERROR | Excel Discussion (Misc queries) | |||
Log of Transactions | Excel Discussion (Misc queries) | |||
Workspace / Transactions | Excel Programming | |||
couting transactions for same time | Excel Worksheet Functions |