Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Maco to copy data from wks to wks

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default Maco to copy data from wks to wks

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
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
Maco code doesn't work. Why? Joe M. Excel Discussion (Misc queries) 2 January 13th 10 07:13 PM
Protect a maco in master copy [email protected] Excel Discussion (Misc queries) 2 March 30th 07 04:20 PM
A simple maco . . . Steve New Users to Excel 3 January 2nd 05 10:36 PM
A simple maco for someone, but not for me. Bill Wilson[_3_] Excel Programming 2 September 21st 04 03:45 PM
Emergency! Can I use Maco to export excel data into word forms mengxue Excel Programming 1 April 30th 04 09:59 AM


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