Splitting an excel work book in to two

S

Shailesh

Hi,
I have an Excel work book and I want to split it in to two csv files
in the same location depening on values in a particular column?
I will reallly appreciate VBA code for this.
 
D

Dave Peterson

I would start a new workbook.
Then open the workbook with the worksheet to split

Filter to show the first value
copy the visible cells
paste into the first worksheet in that newly created workbook

Save that workbook as a CSV file.

Then do the same kind of thing for the second value.
 
S

Shailesh

Hi Dave,
Thank you very much. For example , I have a workbook file.xls with
column A , B,C,D,E,F,G,H,I in sheet1 and depending upon the value
of column D I have to copy column A,B,G,I in to a file called as
file1.csv and else B C D , I in to file file2.csv.

I thought I can write a macros in my worok book and after running
these two files can be created.

Regards,
 
D

Dave Peterson

I would do the same thing as that previous suggestion, but then delete the
columns I didn't want in that new worksheet in the new workbook.

Start recording a macro in the existing workbook before you start anything.
Then stop recording after you've saved to both csv files and closed the new
workbook without saving.

The code should be darn close to what you need.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top