How can I separate a large spreadsheet into worksheets?

G

Guest

I have a large .CSV spreadsheet that shows all of sales history for the
past 12 months. I would like to separate that data into bottom-tabbed
worksheets. I will end up with about 100 worksheets. Our 10-digit customer
code is the first column in the spreadsheet.

When this report was run once a month, I just cut and pasted the data
into separate worksheets manually. However, now the bosses want to be able
to run this report on demand.

If it would make the problem easier, I could break the data down into
separate spreadsheets wneh I export it from the filePro DBMS system. IE,
acmeco.csv, jonesinc.csv, smith.csv, etc.

Thanks!
 
B

Bernie Deitrick

Mike,

Import the CSV file into an Excel workbook, then run the macro below.

HTH,
Bernie
MS Excel MVP

Sub ExportSheetsFromDatabase()
'Based on the value in the first column
Dim myCell As Range
Dim mySht As Worksheet
Dim myName As String
Dim myArea As Range

Set myArea = Range("A1").CurrentRegion.Columns(1).Offset(1, 0).Cells

Set myArea = myArea.Resize(myArea.Rows.Count - 1, 1)

For Each myCell In myArea
On Error GoTo NoSheet
myName = Worksheets(myCell.Value).Name
GoTo SheetExists:
NoSheet:
Set mySht = Worksheets.Add
mySht.Name = myCell.Value
With myCell.CurrentRegion
.AutoFilter Field:=1, Criteria1:=myCell.Value
.SpecialCells(xlCellTypeVisible).Copy _
mySht.Range("A1")
mySht.Cells.EntireColumn.AutoFit
.AutoFilter
End With
Resume
SheetExists:
Next myCell
End Sub
 
G

Guest

Cool! This worked perfectly! It even put the header row at the top of
each worksheet!

Where do I send the Pizza Hut Gift Card???

Mike
(e-mail address removed)
 
G

Guest

Thanks! Bernie's macro did the trick, but I'm going to bookmark your
page just in case I need to modify it.

Mike Schwartz
 
B

Bernie Deitrick

Where do I send the Pizza Hut Gift Card???

Getting a "Thanks!" is sufficient...

Thanks,
Bernie
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top