PDA

View Full Version : Importing columns from another file into current spreadsheet



Prema
02-16-2010, 08:00 AM
Hi All,

Can anyone tell me How do I Import only selected fields OR columns(including Field OR Column names) into Excel? i.e If i want to import only a few columns into current excel sheet from another file.

This file can be of any type like coma OR tab delimited CSV file, OR any other delimited file OR file that may not contain any delimiters at all.

I have some templates which will prompt the user to enter a delimiter, then I need for the user to be able to click a button, which would then bring up an open file dialog, and then once the appropriate file is selected, it should prompt the user to enter the 'number of columns' to be imported into current spreadsheet. Once the number of columns to be imported is entered, again it should prompt the user to select the 'columns' to be imported (i.e if user needs only 2 columns data to be imported into current spreadsheet,after selecting the desired file it should prompt for 2, once its OK, it should prompt for first column name to be imported,then the user to be able to click a button which will prompt for second column name to be imported) and once both the columns have been selected, the selected column names and the selected column's data should be imported into desired columns of current spreadsheet i.e if I fix some columns and rows in current spreadsheet for example A10 ,it should populate the first column into A10,and the next column into B10,... of current spreadsheet. If the user enters a column name i.e not existed in the file to be imported, it should popup a message like 'invalid ' , otherwise it should popup a message like 'Successful'.
If the file to be imported not contain any delimiters it should be able to accept that file with the same above procedure.
And if the user enters ' ,' and try to import Tab delimited file (OR other, other than CSV) it should popup error message.

Thanks,
Prema

domfootwear
02-23-2010, 11:04 PM
Can you post your excel file samples ?

SamT
02-24-2010, 05:25 PM
When you say that it might have no delimiters at all, I assume you don't mean that it has no spaces even though spaces are delimiters.

I am also assuming that this files Rows are delimited by a carriage return.

Can you post a data file, especially one that has "no delimiters at all?"

While you are doing that, consider this program flow:

File Open dialog; select file

Parse first line of file for delimiter type characters (.,;':"/|}{[]()`~_-+*&$#@^ and space

Offer options of delimiter to user

Load file into New_Worksheet

Show Form with Option Buttons labeled with Field/Column Names

User Selects Field/Column Names Buttons

Copy Selected columns to existing or new New_Worksheet
If copied to new New_Worksheet, Insert in Workbook