VBA text to columns

neveu

Board Regular
Joined
Jan 27, 2009
Messages
225
Hello Forum,

i would need your inputs related to a VBA code:

the background is as follows - i have a text file that i need to automatically perform text to column operation. I have recorded the macro to do so but the problem is that it saves the file in a diferent excel file.

what i would need to do when i'm opening the excel (main file.xlsm) file and run the macro is to:
- prompt me the browse window so that i can choose the folder where the text file is located and then select the file
- perform the text to column code and display the results in sheet2 in the current excel file (main file.xlsm)

please find below the code I've recorded. any input on how to change it in order to performed the above mentioned actions would be highly appreciated

Code:
    Workbooks.OpenText Filename:= _
        "C:\Documents and Settings\730001108\Desktop\Stapples\AR GE Stuttgard\opde120511.txt" _
        , Origin:=65001, StartRow:=1, DataType:=xlFixedWidth, FieldInfo:=Array( _
        Array(0, 1), Array(6, 1), Array(33, 1), Array(36, 1), Array(57, 4), Array(66, 4), Array(76, _
        1), Array(85, 1), Array(92, 1), Array(107, 1), Array(123, 1), Array(128, 1)), _
        TrailingMinusNumbers:=True
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top