Sub master()
Call Insert_Blank_Rows
Call copypaste
Call SavetoWB
End Sub
Sub Insert_Blank_Rows()
'Select last row in worksheet.
Selection.End(xlDown).Select
Do Until ActiveCell.Row = 1
'Insert blank row.
ActiveCell.EntireRow.Insert shift:=xlDown
'Move up one row.
ActiveCell.Offset(-1, 0).Select
Loop
End Sub
Sub SavetoWB() 'Excel VBA to export data
Const sPath = "D:\"
Dim ar As Variant
Dim i As Integer
Dim owb As Workbook
Range("A3", Range("A" & Rows.Count).End(xlUp)).AdvancedFilter xlFilterCopy, , [T1], True
ar = Range("T2", Range("T2").End(xlDown))
'Loop through all unique instances of the Results from the Advanced Filter.
For i = 1 To UBound(ar)
Range("A3", Range("A" & Rows.Count).End(xlUp)).AutoFilter 1, ar(i, 1)
Range("A3", Range("N" & Rows.Count).End(xlUp)).Copy 'Where Data is from Col A - N
Set owb = Workbooks.Add
owb.Sheets(1).[A1].PasteSpecial xlPasteValues
owb.SaveAs sPath & [A2]
owb.Close False 'Close no save
Next i
[a3].AutoFilter
Columns(20).EntireColumn.Clear
End Sub
Sub copypaste()
Range("B1").Select
Selection.Cut
Range("B2").Select
ActiveSheet.Paste
Range("D1").Select
Selection.Cut
Range("D2").Select
ActiveSheet.Paste
Range("F1").Select
Selection.Cut
Range("F2").Select
ActiveSheet.Paste
Range("H1").Select
Selection.Cut
Range("H2").Select
ActiveSheet.Paste
End Sub
[\code]
This are the codes you can see it by Alt+F11
and finally this is for changing to csv
[code]
Sub SaveToCSVs()
Dim fDir AsString
Dim wB As Workbook
Dim wS As Worksheet
Dim fPath AsString
Dim sPath AsString
fPath ="C:\temp\pydev\"
sPath ="C:\temp\"
fDir = Dir(fPath)
DoWhile(fDir <>"")
If Right(fDir,4)=".xls"Or Right(fDir,5)=".xlsx"Then
OnErrorResumeNext
Set wB = Workbooks.Open(fPath & fDir)
ForEach wS In wB.Sheets
wS.SaveAs sPath & wS.Name, xlCSV
Next wS
wB.Close False
Set wB =Nothing
EndIf
fDir = Dir
OnErrorGoTo0
Loop
EndSub