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: 35
Default New to Macros

Don't run this macro on the original data !!! Run it on a
copy until you're sure it does what you want. You cannot
undo macros.

My assumption was that there are headings in Cells A1 and
B1 respectively. The macro will identify the individual
record types, add a new sheet to receive the data, then
copy and paste to the new sheet. It can easily be changed
to run on a subset of selected data instead.

Sub Test()
Dim i As Long, X As Long, RowNum As Long
Dim ThisSht As Worksheet, NewSht As Worksheet

Application.ScreenUpdating = False
RowNum = ActiveSheet.Range("A1").End(xlDown).Row + 1
Set ThisSht = ActiveSheet
X = 0
With ThisSht
For i = 2 To RowNum
If .Cells(i, 1) = .Cells(i - 1, 1) Then
X = X + 1
Else
If i 2 Then
Set NewSht = ThisWorkbook.Sheets.Add
NewSht.Name = .Cells(i - 1, 2)
Range("A1") = .Range("A1")
Range("B1") = .Range("B1")
Range(.Cells(i - X - 1, 1), .Cells(i - 1, 2)).Copy
NewSht.Paste Destination:=Range("A2")
NewSht.Columns("A:B").EntireColumn.AutoFit
X = 0
End If
End If
Next
..Activate
End With
Application.CutCopyMode = False
Application.ScreenUpdating = True

End Sub

Regards,
Greg


-----Original Message-----
I am new to Excel macros and need some assistance. I
have a workbook with over 22,000 rows in the first tab. I
would like to create a macro that will create new tabs
and move the contents of the rows at each change in the
value of column A. For example.

Column A Column B
11111 Software
11111 Software 2
11111 Software 3
22222 Wireless
22222 Wireless 2

In this example I would like to move the records (rows)
that have 222222 in column A into a new tab. Any
assistance is appreciated.
.

 
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
Excel 2007 macros - how to merge 5 macros together into one Sue Excel Discussion (Misc queries) 1 April 16th 08 08:36 PM
Macros warning always shows up, even if all macros removed Joe M Excel Discussion (Misc queries) 1 December 20th 07 04:45 AM
Training: More on how to use macros in Excel: Recording Macros ToriT Excel Worksheet Functions 2 February 10th 06 07:05 PM
Parametrized Macros preventing other macros sundar Excel Programming 1 August 18th 03 02:06 PM
List the Macros that can be executed from Tools-Macros Rob Bovey Excel Programming 1 July 10th 03 05:34 PM


All times are GMT +1. The time now is 12:10 PM.

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"