To clarify, you have several rows of data and you want each row sorted to
different Workbooks based on the contents of column E. Copy this code into
the file and run. I think you may want to use another macro to import the
CSV file and then run this code. Let me know if you don't know how to do
this.
Mike
Option Explicit
Sub SortToBooks()
Dim TZ1 As Workbook, TZ2 As Workbook, TZ3 As Workbook, TZ4 As Workbook
Dim cell As Range
Application.ScreenUpdating = False
Set TZ1 = Workbooks.Open("P:\Excel Help\Data Manipulation\Sort Rows To
Different Books\Book1.xls")
Set TZ2 = Workbooks.Open("P:\Excel Help\Data Manipulation\Sort Rows To
Different Books\Book2.xls")
Set TZ3 = Workbooks.Open("P:\Excel Help\Data Manipulation\Sort Rows To
Different Books\Book3.xls")
Set TZ4 = Workbooks.Open("P:\Excel Help\Data Manipulation\Sort Rows To
Different Books\Book4.xls")
For Each cell In UsedRange.EntireRow
Select Case Cells(cell.Row, 5).Value
Case "AL"
cell.Copy
Destination:=TZ1.Worksheets("Sheet1").Cells(TZ1.Sh eets("Sheet1").Cells(65536,
5).End(xlUp).Row + 1, 1)
Case "AZ"
cell.Copy
Destination:=TZ2.Worksheets("Sheet1").Cells(TZ2.Sh eets("Sheet1").Cells(65536,
5).End(xlUp).Row + 1, 1)
Case "FL"
cell.Copy
Destination:=TZ3.Worksheets("Sheet1").Cells(TZ3.Sh eets("Sheet1").Cells(65536,
5).End(xlUp).Row + 1, 1)
Case "NM"
cell.Copy
Destination:=TZ4.Worksheets("Sheet1").Cells(TZ4.Sh eets("Sheet1").Cells(65536,
5).End(xlUp).Row + 1, 1)
Case Else
End Select
Next cell
TZ1.Save
TZ2.Save
TZ3.Save
TZ4.Save
TZ1.Close
TZ2.Close
TZ3.Close
TZ4.Close
Application.ScreenUpdating = True
End Sub
"joetcb" wrote:
I receive a list daily of all new business', that are in a CSV format.
I am trying to figure out the formula that "if AZ is in column E then
sent the record Book 1, if AL is in column E then send the record to
Book 2, etc"
Basically I wish to place them in 4 separate books/sheets (for the 4
time zones)
Thanks in advance to all advice
--
joetcb
------------------------------------------------------------------------
joetcb's Profile: http://www.excelforum.com/member.php...o&userid=34534
View this thread: http://www.excelforum.com/showthread...hreadid=563326