Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
moving data to multiple tabs
Hello,
I have a spreadsheet with multiple divisions that I need to split out into separate tabs. I would like to do this with a macro if possible. Example: grp# division center 1 teamA 123 2 teamB 456 3 teamC 789 Thank you! |
#2
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
moving data to multiple tabs
the following code sorts the data on Sheet1 using the division name. The
copies each Division to its own new worksheet. Sub splitdata() With Sheets("Sheet1") 'sort data to get divisions LastRow = .Range("A" & Rows.Count).End(xlUp).Row Set DataRange = .Rows("2:" & LastRow) DataRange.Sort _ key1:=.Range("B2"), _ Order1:=xlAscending, _ Header:=xlNo First = 2 For RowCount = 2 To LastRow If .Range("B" & RowCount) < .Range("B" & (RowCount + 1)) Then Division = .Range("B" & RowCount) Set newsht = Sheets.Add(after:=Sheets(Sheets.Count)) newsht.Name = Division 'copy Header Row .Rows(1).Copy Destination:=newsht.Rows(1) .Rows(First & ":" & RowCount).Copy _ Destination:=newsht.Rows(2) First = RowCount + 1 End If Next RowCount End With End Sub "Cathy Landry" wrote: Hello, I have a spreadsheet with multiple divisions that I need to split out into separate tabs. I would like to do this with a macro if possible. Example: grp# division center 1 teamA 123 2 teamB 456 3 teamC 789 Thank you! |
#3
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
moving data to multiple tabs
Hi Joel,
That worked like a charm!! Thank you so much :) "Joel" wrote: the following code sorts the data on Sheet1 using the division name. The copies each Division to its own new worksheet. Sub splitdata() With Sheets("Sheet1") 'sort data to get divisions LastRow = .Range("A" & Rows.Count).End(xlUp).Row Set DataRange = .Rows("2:" & LastRow) DataRange.Sort _ key1:=.Range("B2"), _ Order1:=xlAscending, _ Header:=xlNo First = 2 For RowCount = 2 To LastRow If .Range("B" & RowCount) < .Range("B" & (RowCount + 1)) Then Division = .Range("B" & RowCount) Set newsht = Sheets.Add(after:=Sheets(Sheets.Count)) newsht.Name = Division 'copy Header Row .Rows(1).Copy Destination:=newsht.Rows(1) .Rows(First & ":" & RowCount).Copy _ Destination:=newsht.Rows(2) First = RowCount + 1 End If Next RowCount End With End Sub "Cathy Landry" wrote: Hello, I have a spreadsheet with multiple divisions that I need to split out into separate tabs. I would like to do this with a macro if possible. Example: grp# division center 1 teamA 123 2 teamB 456 3 teamC 789 Thank you! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Sum Multiple Tabs of Data | Excel Discussion (Misc queries) | |||
Moving data from multiple rows into a single row | Excel Discussion (Misc queries) | |||
Moving data between sheets (tabs?) | Charts and Charting in Excel | |||
Moving data from multiple cells to one column | Excel Discussion (Misc queries) | |||
Combining Data multiple tabs | Excel Discussion (Misc queries) |