I had to write a macro to do this just yesterday. If you know VBA at all,
you can modify the code to suit your needs. In this example, I was taking
the "Price Sheet" and splitting it into 4 regional worksheets. The 4
regional worksheets were already created. The region name was in column 7
of the Price Sheet.
Good luck
Sub WriteRegions()
' This macro was written by Frank Hayes on May 4, 2007
Application.ScreenUpdating = False
' See how many Rows and Columns are in the selected range
Set ws1 = ActiveWorkbook.Worksheets("Price Sheet")
ws1.Activate
Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
P1TotalRows = Selection.Rows.Count
P1TotalCols = Selection.Columns.Count
' Redim the array to match the selected range
ReDim P1Array(1 To P1TotalRows, 1 To P1TotalCols)
ReDim EU_Array(1 To P1TotalRows, 1 To P1TotalCols)
ReDim NA_Array(1 To P1TotalRows, 1 To P1TotalCols)
ReDim AP_Array(1 To P1TotalRows, 1 To P1TotalCols)
ReDim LA_Array(1 To P1TotalRows, 1 To P1TotalCols)
' Load the selected range into an array
ws1.Activate
ws1.Range("PriceData").Select
P1Array = Selection
' Redim the array to match the selected range
NewCols1 = P1TotalCols + 1
' Split the regions
ReDim TempArray(1 To P1TotalRows + 1, 1 To NewCols1)
i = 1
j = 1
k = 1
L = 1
' The column I want to split on is in column 7 in this workbook
SplitCol = 7
For X = 1 To UBound(P1Array)
If P1Array(X, SplitCol) = "REGION NA" Then
For Y = 1 To P1TotalCols
NA_Array(i, Y) = P1Array(X, Y)
Next
i = i + 1
ElseIf P1Array(X, SplitCol) = "EU" Then
For Y = 1 To P1TotalCols
EU_Array(j, Y) = P1Array(X, Y)
Next
j = j + 1
ElseIf P1Array(X, SplitCol) = "AP" Then
For Y = 1 To P1TotalCols
AP_Array(k, Y) = P1Array(X, Y)
Next
k = k + 1
ElseIf P1Array(X, SplitCol) = "LJ" Then
For Y = 1 To P1TotalCols
LA_Array(L, Y) = P1Array(X, Y)
Next
L = L + 1
End If
Next
Sheets("Europe").Range("A2").Resize(UBound(EU_Array), P1TotalCols) =
EU_Array
Sheets("North America").Range("A2").Resize(UBound(NA_Array),
P1TotalCols) = NA_Array
Sheets("Latin America").Range("A2").Resize(UBound(LA_Array),
P1TotalCols) = LA_Array
Sheets("Asia Pacific").Range("A2").Resize(UBound(AP_Array), P1TotalCols)
= AP_Array
' Finish Out
Application.ScreenUpdating = True
Application.StatusBar = " "
MsgBox "The regions have been split."
End Sub