Create file xls based on colums & populate data with criteria
Solved/Closed
Steveryde
Posts
3
Registration date
Tuesday May 13, 2014
Status
Member
Last seen
May 14, 2014
-
May 13, 2014 at 05:42 AM
Steveryde Posts 3 Registration date Tuesday May 13, 2014 Status Member Last seen May 14, 2014 - May 14, 2014 at 09:05 AM
Steveryde Posts 3 Registration date Tuesday May 13, 2014 Status Member Last seen May 14, 2014 - May 14, 2014 at 09:05 AM
Related:
- Create file xls based on colums & populate data with criteria
- Create skype account with gmail - Guide
- Windows 10 iso file download 64-bit - Download - Windows
- Kmspico zip file download - Download - Other
- Snapchat create account with email - Guide
- Create instagram account on pc - Guide
4 responses
TrowaD
Posts
2921
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
December 27, 2022
555
May 13, 2014 at 10:50 AM
May 13, 2014 at 10:50 AM
Hi Steveryde,
Do you have anything against applying autofilter?
Filter on "F-Intermediary Code", copy entire sheet, open new workbook, paste data and save workbook as "F-Intermediary Code".
Best regards,
Trowa
Do you have anything against applying autofilter?
Filter on "F-Intermediary Code", copy entire sheet, open new workbook, paste data and save workbook as "F-Intermediary Code".
Best regards,
Trowa
Steveryde
Posts
3
Registration date
Tuesday May 13, 2014
Status
Member
Last seen
May 14, 2014
May 13, 2014 at 11:23 AM
May 13, 2014 at 11:23 AM
Sorry, I'ven't understand.
I gave you an example, in the "original" file arretrati.xlsx I have the intermediary code in the column F (same code many rows). In the other colums I have many other information (column A - Name, Column B Address, Column C policy, etc).
Ando so for the intermediary 0001 in the arretrati.xlsx I have 10 rows, then i need to create the file 0001.xlsx with 10 rows, for the intermediary 0002 35 rows, i need to create the file 0002.xlsx with the 35 rows....and so on.
I can do this with the autofilter?
I gave you an example, in the "original" file arretrati.xlsx I have the intermediary code in the column F (same code many rows). In the other colums I have many other information (column A - Name, Column B Address, Column C policy, etc).
Ando so for the intermediary 0001 in the arretrati.xlsx I have 10 rows, then i need to create the file 0001.xlsx with 10 rows, for the intermediary 0002 35 rows, i need to create the file 0002.xlsx with the 35 rows....and so on.
I can do this with the autofilter?
TrowaD
Posts
2921
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
December 27, 2022
555
May 13, 2014 at 12:18 PM
May 13, 2014 at 12:18 PM
Hi Steveryde,
Yeah, I thought maybe you wanted to do this with one criteria.
To know which criteria to look for I created a sheet "Filterlist" (create this sheet in your original file "arretrati.xlsx"). On this sheet I used column A to put the criteria's. So A1 = 0001, A2 = 0002 and so on.
Then I run the code below to:
- filter data based on the criteria's found in the "Filterlist" Sheet.
- copy/paste filter result in new workbook.
- save workbook as criteria's name and close workbook.
Try it and see if it yields the desired result.
Best regards,
Trowa
Yeah, I thought maybe you wanted to do this with one criteria.
To know which criteria to look for I created a sheet "Filterlist" (create this sheet in your original file "arretrati.xlsx"). On this sheet I used column A to put the criteria's. So A1 = 0001, A2 = 0002 and so on.
Then I run the code below to:
- filter data based on the criteria's found in the "Filterlist" Sheet.
- copy/paste filter result in new workbook.
- save workbook as criteria's name and close workbook.
Try it and see if it yields the desired result.
Sub RunMe() Dim x As Integer Dim sValue As String x = 1 Do sValue = Sheets("Filterlist").Cells(x, 1) Cells.AutoFilter Field:=6, Criteria1:=sValue Cells.Copy Workbooks.Add ActiveWorkbook.Sheets(1).Range("A1").PasteSpecial ActiveWorkbook.SaveAs ("C:\MyDocuments\" & sValue & ".xls") 'Make sure both filepath and extention are correct ActiveWorkbook.Close x = x + 1 Loop Until Sheets("Filterlist").Cells(x, 1) = vbNullString Cells.AutoFilter End Sub
Best regards,
Trowa
Steveryde
Posts
3
Registration date
Tuesday May 13, 2014
Status
Member
Last seen
May 14, 2014
May 14, 2014 at 09:05 AM
May 14, 2014 at 09:05 AM
Hi Trowa,
Thanks a lot for your precious help.
I've changed the code you wrote for me because it doesn't run under my excel.
Here the code modified:
---------------------------------------------------------------------
Sub CreaFileIntermediario()
Dim x As Integer
Dim sValue, sPath As String
Dim My_Range As Range
Dim LastRow As Long
x = 2
sPath = ActiveWorkbook.Path
Sheets("Arretrati").Select
Range("A2").Select
LastRow = Cells(Cells.Rows.Count, "A").End(xlUp).Row
Set My_Range = Range("A1:Q" & LastRow)
My_Range.Parent.Select
Do
sValue = Sheets("Filterlist").Cells(x, 1)
My_Range.Parent.AutoFilterMode = False
My_Range.AutoFilter Field:=2, Criteria1:=sValue
My_Range.Copy
Workbooks.Add
ActiveWorkbook.Sheets(1).Range("A1").PasteSpecial
ActiveWorkbook.SaveAs (sPath & "\" & sValue & ".xlsx")
ActiveWorkbook.Close
x = x + 1
Loop Until Sheets("Filterlist").Cells(x, 1) = vbNullString
Cells.AutoFilter
End Sub
---------------------------------------------------------------------
I hope that this code could help somebody else.
Regards
Thanks a lot for your precious help.
I've changed the code you wrote for me because it doesn't run under my excel.
Here the code modified:
---------------------------------------------------------------------
Sub CreaFileIntermediario()
Dim x As Integer
Dim sValue, sPath As String
Dim My_Range As Range
Dim LastRow As Long
x = 2
sPath = ActiveWorkbook.Path
Sheets("Arretrati").Select
Range("A2").Select
LastRow = Cells(Cells.Rows.Count, "A").End(xlUp).Row
Set My_Range = Range("A1:Q" & LastRow)
My_Range.Parent.Select
Do
sValue = Sheets("Filterlist").Cells(x, 1)
My_Range.Parent.AutoFilterMode = False
My_Range.AutoFilter Field:=2, Criteria1:=sValue
My_Range.Copy
Workbooks.Add
ActiveWorkbook.Sheets(1).Range("A1").PasteSpecial
ActiveWorkbook.SaveAs (sPath & "\" & sValue & ".xlsx")
ActiveWorkbook.Close
x = x + 1
Loop Until Sheets("Filterlist").Cells(x, 1) = vbNullString
Cells.AutoFilter
End Sub
---------------------------------------------------------------------
I hope that this code could help somebody else.
Regards