View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
crispbd[_3_] crispbd[_3_] is offline
external usenet poster
 
Posts: 1
Default Exporting columns in excel file to csv format


Just copy and paste the code below into a new module in your master
data workbook and run "ExportToCSV"


Sub ExportToCSV()

On Error Resume Next
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Dim RefPage As Object
Dim NewWB As Object

'setup reference page

Set RefPage = ThisWorkbook.Sheets(1)

' change this to the master data sheet we are copying from

'Adata stores the A column Data
'OtherData stores the B, C, D, .... , CN column data

Dim Adata As Object, OtherData As Object

'loops B to CN columns

For colcount = 2 To 92
Set NewWB = Workbooks.Add
Set Adata = RefPage.Range("a6:a4006")
Adata.Copy
NewWB.Sheets(1).Select
NewWB.Sheets(1).Cells(1, 1).Select: ActiveSheet.Paste
Set OtherData = RefPage.Range(RefPage.Cells(6, colcount)
RefPage.Cells(4006, colcount))
OtherData.Copy
NewWB.Sheets(1).Select
NewWB.Sheets(1).Cells(1, 2).Select: ActiveSheet.Paste
NewWB.SaveAs Filename:=RefPage.Cells(5, colcount).Value & ".csv"
_
FileFormat:=xlCSV, CreateBackup:=False
NewWB.Close
Next
Application.ScreenUpdating = True

End Su

--
crispb
-----------------------------------------------------------------------
crispbd's Profile: http://www.excelforum.com/member.php...fo&userid=1088
View this thread: http://www.excelforum.com/showthread.php?threadid=27363