Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default 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
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
Last few transactions Mohan Babu Excel Worksheet Functions 8 October 15th 09 05:00 PM
Grouping daily transactions in a pivot table by month - CANNOT GROUPTHAT SELECTION ERROR Dave K Excel Discussion (Misc queries) 1 February 7th 09 05:56 PM
Log of Transactions Snakeoids Excel Discussion (Misc queries) 1 October 27th 07 12:48 AM
Workspace / Transactions Paulo Excel Programming 3 May 1st 07 02:03 PM
couting transactions for same time kdp145 Excel Worksheet Functions 1 December 15th 05 04:50 PM


All times are GMT +1. The time now is 03:23 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"