Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Difficult Looping Macro€¦with AutoFilter
This is kind of difficult to explain, but here goes. Below I have a loop
(code is below) that filters items in AA1:AA11 and copies pastes the results into A3:A6, and loops through all items in the list of names in AA and it even assigns the persons name to the Worksheet tab. It is actually very nice, and I tip my hat to Joel for putting this together for me!! Now, the requirements have changed a bit and Id like to know if the following is possible€¦ Is there a way to modify this macro to apply the AutoFilter to ColumnAA, copy/paste the name into Range A3:A6 (this will always be the same), then turn off the filter, move to ColumnAB, apply the filter, and filter names in AB (these are the same names), and then copy the resulting items in AB:AC, and paste these in A11:B15 (copied down five times), then skip a row, and then go back to AB and get the next names in AB and the adjacent AC, and copy/paste these into lets say A17:B17 (remember A11:B11, then copied down 5 then skip a row). After Excel gets to the end of the list in AB (which is variable and always of different length) I would need it to turn off the filter in AB:AC and go to AD:AF and again apply the filter and copy/paste names in AD:AF and do the same as above, starting in the first unused cell in Column A (at this point I dont know how far down I will be in ColumnA). I know this is asking a heck of a lot. The looping stuff has always been tricky for me. Ive been working on this since early this morning. Ive tried many things in Access and Excel too (of course). Although it is very complex, I think this is the best, and most feasible, solution. However, if someone has a better solution I am open to suggestions!! Anyway, if someone here understands my need, PLEASE post back with what you think would be a solution, and Ill try to make some modifications if it doesnt work, and together, hopefully, we can get this thing working. Sub SheetsRVP() With Sheets("RVP") lstRw = .Cells(Rows.Count, "AA").End(xlUp).Row For Each C In .Range("AA1:AA11") C.Copy ..Range("A3:A6").PasteSpecial Paste:=xlPasteValues Set newsht = Sheets.Add(after:=Sheets(Sheets.Count)) ..Range("A1:O17").Copy _ Destination:=newsht.Range("A1") newsht.Cells.Columns.AutoFit Columns("K:K").Select Selection.ColumnWidth = 20 Range("A1").Select newsht.Name = "RVP - " & C Next C End With End Sub Regards, Ryan--- -- RyGuy |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
excel 2007 autofilter change to 2003 autofilter functionality? | Excel Discussion (Misc queries) | |||
2007 excel autofilter back to 2003 autofilter? | Excel Discussion (Misc queries) | |||
2007 excel autofilter change back to 2003 autofilter? | Excel Discussion (Misc queries) | |||
2007 Autofilter worse than 2003 Autofilter | Excel Discussion (Misc queries) | |||
AutoFilter, Looping through the Rows? (Newbie) | Excel Programming |