I need a macro that will prompt the user to open a .txt file and bring into excel and separate columns based on fixed width like below.
12, 51, 60, 63, 68, 75, 79, 83, 90, 93, 97, 104, 107, 111, 118, 121, 125.
I need a macro that will prompt the user to open a .txt file and bring into excel and separate columns based on fixed width like below.
12, 51, 60, 63, 68, 75, 79, 83, 90, 93, 97, 104, 107, 111, 118, 121, 125.
But that's not a fixed width. But delimited by comma.
I.E. 12, has different width than 121,
Can't you just use native text import wizard?
0.JPG
?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
― Robert A. Heinlein
I could but the person using this file is very excel naïve. I thought I could add this to the macro I already have her using. She doesn't think she can handle opening a text file and then splitting the columns into the right fields.
VBA is more prone to error than import wizard. As you need to code to handle errors etc.
If you must, I'd start off by recording the steps you take to import the file using text wizard (using macro recorder). That will give you the code base to customize.
It will be easier for you to maintain than custom codes, I'd imagine.
Ex:
Now you just have to customize it to suite your need.Please Login or Register to view this content.
If you are interested in importing text file through methods other than native Excel tool, google "freefile() and import text file", you will find plenty of example on it.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks