Hi guys,
I am a very new user to VBA and am trying to utilise a macro to help with a batch export from a very large dataset.
The dataset is 1872 columns wide and 1285 rows. What I am trying to achieve is to do a batch selection and export to csv of the dataset. I am trying to select columns 1:6 and export as a csv, then select 7:12 and export as a csv etc until the end of the dataset.
So the end result is that I should have 312 csv files.
I have tried to record a macro to complete the process for the first csv, but am unsure how to then increment by data selection by 6 columns and loop it until the end.
if anyone has some tips or comments it would be really appreciated.
My code is below:
I am a very new user to VBA and am trying to utilise a macro to help with a batch export from a very large dataset.
The dataset is 1872 columns wide and 1285 rows. What I am trying to achieve is to do a batch selection and export to csv of the dataset. I am trying to select columns 1:6 and export as a csv, then select 7:12 and export as a csv etc until the end of the dataset.
So the end result is that I should have 312 csv files.
I have tried to record a macro to complete the process for the first csv, but am unsure how to then increment by data selection by 6 columns and loop it until the end.
if anyone has some tips or comments it would be really appreciated.
My code is below:
Code:
Sub Macro2()
'
' Macro2 Macro
'
'
Columns("A:F").Select
Selection.Copy
Sheets("Sheet1").Select
Range("A1").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ChDir "C:\Users\Glen\AppData\Roaming\Microsoft\Templates"
ActiveWorkbook.SaveAs Filename:= _
"C:\Users\Glen\AppData\Roaming\Microsoft\Templates\EMN_001.csv", FileFormat:= _
xlCSV, CreateBackup:=False
End Sub