Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel 2007 macros - how to merge 5 macros together into one | Excel Discussion (Misc queries) | |||
Macros warning always shows up, even if all macros removed | Excel Discussion (Misc queries) | |||
Training: More on how to use macros in Excel: Recording Macros | Excel Worksheet Functions | |||
Parametrized Macros preventing other macros | Excel Programming | |||
List the Macros that can be executed from Tools-Macros | Excel Programming |