MrExcel Publishing
Your One Stop for Excel Tips & Solutions

CHALLENGE: Importing a txt file with a macro!!!!

Posted by Conor on October 26, 2001 2:39 AM

Hello all,

while i automatically open a spreadsheet with a macro is it possible to import a txt file (csv) that needs to have a few fields formatted(ie set to txt,gen,date) and the first line of data at line 12 always.

Can a macro handle this? ie can i insantiate the process of file, import txt file, setting the field types, choosing comma as a delimiter, starting @ line 12.

what i am trying to do is on pressing a button - import the txt file to avoid the user having to do this!!!

thanks all for any help!!

Posted by Dan on October 26, 2001 4:35 AM

That's precisely what the macros are for! Have you ever tried to use the Macro recorder? That would probably be the easiest way for you to accomplish what you are doing. Someone could write some code for you to do this as well, but we would probably need some more information (which columns need to be formatted, etc).

Try looking up information in Excel's help file under "macros, recorder" and see if that gets you the information you want. If not, just reply back and we'll help you through it.