I have a workbook with many tabs that currently will create a folder and save each tab as a separate CSV file into that folder.
Ultimately, what I'd like so for those files to then combine into one big CSV file.
The headers of each tab are identical, so I only need the header row once.
My macro for the exporting as CSV files is:
I've googled and found some ways to have files in a folder combine, but I can't figure out how to combine that so that it reads the files in the folder that the above macro created, and I can't figure out how to get the header row (1:1) to print only once. (There is not a fixed number of cells, so I just need it to print whatever has content below 1:1... one week it could be 1000 rows, the next 900 rows, then 1200 rows, etc.)
Anyone able to help me out? Pretty please?
Ultimately, what I'd like so for those files to then combine into one big CSV file.
The headers of each tab are identical, so I only need the header row once.
My macro for the exporting as CSV files is:
Code:
Sub SplitWorkbook()
CarryOn = MsgBox("Do you want to export CSV files? NOTE: This may take up to 60 seconds.", vbYesNo, "Export CSV Test Files")
If CarryOn = vbYes Then
ActiveWorkbook.Save
Dim FileExtStr As String
Dim FileFormatNum As Long
Dim xWs As Worksheet
Dim xWb As Workbook
Dim FolderName As String
Application.ScreenUpdating = False
Set xWb = Application.ThisWorkbook
DateString = Format(Now, "mm-dd-yyyy hh-mm-ss")
FolderName = xWb.Path & "" & "EU Test Cases " & DateString
MkDir FolderName
For Each xWs In xWb.Worksheets
If (xWs.Name <> "Taxonomy") And (xWs.Name <> "Master") And (xWs.Name <> "Directions") And (xWs.Name <> "EU Shipping & Gift Wrap") And (xWs.Name <> "Tax Rates") And (xWs.Name <> "RuleFile") And (xWs.Name <> "TDM") Then
xWs.Copy
If Val(Application.Version) < 12 Then
FileExtStr = ".csv": FileFormatNum = 6
Else
Select Case xWb.FileFormat
Case 51:
FileExtStr = ".csv": FileFormatNum = 6
Case 52:
If Application.ActiveWorkbook.HasVBProject Then
FileExtStr = ".csv": FileFormatNum = 6
Else
FileExtStr = ".csv": FileFormatNum = 6
End If
Case 56:
FileExtStr = ".csv": FileFormatNum = 6
Case Else:
FileExtStr = ".csv": FileFormatNum = 6
End Select
End If
xFile = FolderName & "" & Application.ActiveWorkbook.Sheets(1).Name & FileExtStr
Application.ActiveWorkbook.SaveAs xFile, FileFormat:=FileFormatNum
Application.ActiveWorkbook.Close False
End If
Next xWs
MsgBox "You can find the files in " & FolderName
Application.ScreenUpdating = True
End If
End Sub
Anyone able to help me out? Pretty please?
Last edited: