Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Import CSV into Mulitple Excel Worksheets

Status
Not open for further replies.

Bumpthis

IS-IT--Management
Nov 5, 2001
16
GB
Hi
I'm very new to coding and was wondering how i could import 1 csv file into my excel workbook but for every different item in the csv file generate a new worksheet for each instance please
so for example the csv file contains
Header1 Header2
A 10
B 10
C 10
A 20

I would need to create a new worksheet per unique value in Header1 so 3 new worksheets in this instance A,B and one for C

Many Thanks in Advance
:->
 


Hi,

Very BAD idea to chop up similar data into multiple sheets. It is certainly NOT accepted and best practice for table design.

You can, however, REPORT from the source data on as many sheets as you like. But even THAT is not as good a practice as, for instance, using a PivotTable with a Page Field to select the portion of data you are interested in, or using the AutoFilter in the source data table to display the subset of data that meets your cirteria.

Skip,

[glasses] [red][/red]
[tongue]
 
Have you tried to import the csv into a single sheet, then sort on Header1 and finally play with an autofilter to copy the relevant data ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
or something like:

Code:
Sub insertsheets()
On Error Resume Next
x = 2
cursht = ActiveSheet.Name
Do While Sheets(cursht).Cells(x, 1) <> ""
    Sheets.Add
    ActiveSheet.Name = Sheets(cursht).Cells(x, 1)
    x = x + 1
Loop
End Sub

which assumes the first Header record is on row 2 and you want to name all of the sheets the same as the Header.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top