LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default Checking for a minimum of 5 rows

I have a procedure that sorts a list of reps by their id and then transaction
amount. Then copies the top 5 transactions to another sheet. The problem is
when a rep has less than 5 transactions it throws off the other spreadsheet
from that point on. I need something that checks to see if the rep has 5
transactions and if he doesn't it tacks on the appropriate amount of "dummy"
transactions to make a total of 5 and then copies those 5 transactions to the
other sheet. How can I do this? Here's the code I have so far:

Sub TallySheetRepDump()
Call BanSumSort
NewRow = 6
With Sheets("Catalyst Dump")
'The following line of code calculates the number of rows of data
LastRow = .Range("B" & Rows.Count).End(xlUp).Row
'Sort by UID (column A) then by Transaction Amount (column F)
.Rows("2:" & LastRow).Sort _
Key1:=.Range("A2"), _
Order1:=xlAscending, _
Key2:=.Range("F2"), _
Order2:=xlAscending, _
Header:=xlNo

Start = 1
NewRow = 6
'Outer loop for entire worksheet. There is an error here if the
'rep doesn't have 5 or more adjustments in Catalyst Dump
For RowCount = Start To LastRow
'Check to see if RowCount is equal to the next row. If not that
'means the name has changed and we want to capture the info for
'the current rep
If .Range("A" & RowCount) < .Range("A" & (RowCount + 1)) Then
'If name changes make sure the rep has 5 or more transactions
StartRow = RowCount + 1
RowCount = RowCount + 5
'If rep has at least 5 transactions then copy the first 5 and
'move them to the Tally Sheet
If .Range("A" & StartRow) = .Range("A" & RowCount) Then
.Range("A" & StartRow & ":F" & RowCount).Copy _
Destination:=Sheets("Tally Sheet").Range("A" & NewRow)
.Range("G" & StartRow & ":Q" & RowCount).Copy _
Destination:=Sheets("Tally Sheet").Range("N" & NewRow)
NewRow = NewRow + 8
Else
'this is where I need something that inserts "dummy"
transactions
'to give the rep a total of 5 and then copy to the other sheet
End If
End If
Next RowCount
End With
 
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
Checking for duplication on rows Karmen New Users to Excel 2 February 8th 06 05:22 AM
Checking Blank Rows AccessHelp Excel Programming 4 January 16th 06 03:42 PM
minimum along rows [email protected] Excel Worksheet Functions 12 August 25th 05 02:15 PM
Finding the minimum in a selected number of rows of the same colum Mark Rugers Excel Worksheet Functions 5 July 20th 05 10:37 PM
Finding minimum value across selected rows of an array Dazed and confused about min, max Excel Worksheet Functions 2 February 25th 05 11:11 PM


All times are GMT +1. The time now is 11:27 AM.

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

About Us

"It's about Microsoft Excel"