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 NEED HELP! Macro loop

I need help writing a macro. I recorded a macro (posted below) to show you
what I'm doing. The problem is I need it to repeat this process every 8
rows. Here's my starting point:

Sub TallySheetRepDump()
'
' TallySheetRepDump Macro
' Macro recorded 3/31/2009 by Osiris
'

'
Sheets("Catalyst Dump").Select
Cells.Select
Selection.Sort Key1:=Range("B2"), Order1:=xlAscending, Key2:=Range("F2") _
, Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal,
DataOption2 _
:=xlSortNormal
Range("A2:F6").Select
Selection.Copy
Sheets("Tally Sheet").Select
Range("A6").Select
ActiveSheet.Paste
Sheets("Catalyst Dump").Select
Range("G2:Q6").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Tally Sheet").Select
Range("N6").Select
ActiveSheet.Paste
End Sub

The "Catalyst Dump" sheet contains several different reps with each rep
having between 20 and 300 transactions (or rows per rep). It changes every
week so one week I may have 10 reps and the next week I may have 40 reps. So
the first part is me sorting "Catalyst Dump" 1st by rep then by transaction
amount. I'm only interested in the 5 highest transactions for each rep so I
take the top 5 rows in the first 6 columns of "Catalyst dump" and copy them.
I then move to the "Tally Sheet" sheet and paste that info starting at cell
A6. I go back to "Catalyst Dump" and copy the remaining columns of
information (same top 5 rows) and I move that over to the "Tally Sheet"
sheet. Paste that info in starting at cell N6.

Now here's the tricky part. I need to repeat this same process for as many
reps as I have data for in "Catalyst Dump." So if I have 10 reps in
"Catalyst Dump" then I need to repeat the process 10 times. Each time the
reps data is placed in "Tally Sheet" starting at every 8th row. In other
words, in this first part you see above, the macro takes the first reps info
from "Catalyst Sheet" and dumps in rows 6-10 in "Tally Sheet". Then I need
to move to the second rep in "Catalyst Dump" and copy that reps info to
"Tally Sheet" in rows 14-18. Then take the third reps info from "Catalyst
Dump" and paste that in "Tally Sheet" rows 22-26. So on and so forth and
until the last rep in "Catalyst Dump".

I know this require some "coding" to accomplish which is why I need help.
After copying the top 5 rows for a rep I don't know how to delete the
remaining rows for that rep and move to the next rep. Nor do I know how to
make the following reps data paste every 8th row in "Tally Sheet".

Thanks in advance for you help. This is for a project and my deadline is
fast approaching.
 
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
Loop Macro KalliKay Excel Programming 2 September 16th 08 10:47 PM
Loop to run macro each row PST Excel Discussion (Misc queries) 1 May 17th 07 06:36 AM
Do until loop with use of another macro in loop The Excelerator Excel Programming 9 February 28th 07 02:28 AM
Need to loop my macro David Excel Programming 4 December 25th 05 02:14 PM
VBA Macro Loop Neutron1871 Excel Programming 1 November 4th 04 09:22 AM


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