Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi All,
I need a maco that would look down column b and at each change of data copy the previous rows to a new sheet. John books John books Kate puzzles Kate puzzles The macro would copy the first two rows to a new sheet and then the next tow rows to a new sheet ect. Any help would be greatly appreciated. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Tammy,
Maybe something like this: Sub test() Dim lLastRow As Long Dim rngCopy As Range Dim s As Worksheet Dim c As Range lLastRow = UsedRange.SpecialCells(xlCellTypeLastCell).Row For Each c In Range("B1:B" & lLastRow) If rngCopy Is Nothing Then Set rngCopy = c Else Set rngCopy = Application.Union(rngCopy, c) End If If c.Value < c.Offset(1).Value Then Set s = ThisWorkbook.Worksheets.Add(After:=Sheets(Sheets.C ount)) rngCopy.EntireRow.Copy s.Range("A1") Set rngCopy = Nothing End If Next c End Sub -- Hope that helps. Vergel Adriano "Tammy H" wrote: Hi All, I need a maco that would look down column b and at each change of data copy the previous rows to a new sheet. John books John books Kate puzzles Kate puzzles The macro would copy the first two rows to a new sheet and then the next tow rows to a new sheet ect. Any help would be greatly appreciated. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Maco code doesn't work. Why? | Excel Discussion (Misc queries) | |||
Protect a maco in master copy | Excel Discussion (Misc queries) | |||
A simple maco . . . | New Users to Excel | |||
A simple maco for someone, but not for me. | Excel Programming | |||
Emergency! Can I use Maco to export excel data into word forms | Excel Programming |