Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 37
Default 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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 9,101
Default 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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 37
Default 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
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
Sum Multiple Tabs of Data SMH Excel Discussion (Misc queries) 2 January 24th 08 11:04 PM
Moving data from multiple rows into a single row GfW Excel Discussion (Misc queries) 3 September 28th 07 06:13 AM
Moving data between sheets (tabs?) Fredrik Wenngren Charts and Charting in Excel 0 February 7th 07 02:02 PM
Moving data from multiple cells to one column [email protected] Excel Discussion (Misc queries) 2 June 28th 06 02:15 AM
Combining Data multiple tabs zero760 Excel Discussion (Misc queries) 2 August 30th 05 11:00 PM


All times are GMT +1. The time now is 09:18 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"