I am having trouble setting up the pattern recognition part of the macro for importing part of a .txt file. The part of the file I want imported looks like
There is more to the file above this with varying row #'s - meaning no fixed rows #'s or pattern
Component,Heading1,Heading2,Heading 3, Heading 4,Heading5
1, 0.100E+11, 0.000E+00, 0.100E+11, 0.100E+11
2, 0.100E+11, 0.000E+00, 0.100E+11, 0.100E+11
3, 0.100E+11, 0.000E+00, 0.100E+11, 0.100E+11
4, 0.100E+11, 0.000E+00, 0.100E+11, 0.100E+11
5, 0.100E+11, 0.000E+00, 0.100E+11, 0.100E+11
6, 0.100E+11, 0.000E+00, 0.100E+11, 0.100E+11
7, 0.100E+11, 0.000E+00, 0.100E+11, 0.100E+11
8, 0.100E+11, 0.000E+00, 0.100E+11, 0.100E+11
There is more to the file below this with varying row #'s - meaning no fixed row #'s or pattern
What I need is to be able to do is essentially copy the part that starts with Component and then include all the lines below it up to a textbox defined value +1 eg:
D = Val(SimulationsTextBox.Text) +1 (the simulations text box will always be different so I need to have this variable as part of the pattern recognition and this is already defined elsewhere)
and in the above example the simulations text box value is 8 so it copies 9 lines total starting with Component
Unfortunately this value will always change and I cannot use the standard import file, plus the file is very large so I cannot copy all the file starting with Component then delete the rows I do not need- I just need those 9 lines in this example.
I already know how to open the file and/or read it. I am just looking for the code for the pattern that lets me highlight the desired section and import them into cell A1 of sheet 2 in the already open excel file.
Please describe what each line of code does because I am a beginner at VB and Excel Macro coding.
Once that selection is imported into excel I would like to split it up into separate cells using comma delineated method.
Due to large file size, listing the fastest way for VB to execute this would be greatly appreciated.
Thanks,
Jeremy
There is more to the file above this with varying row #'s - meaning no fixed rows #'s or pattern
Component,Heading1,Heading2,Heading 3, Heading 4,Heading5
1, 0.100E+11, 0.000E+00, 0.100E+11, 0.100E+11
2, 0.100E+11, 0.000E+00, 0.100E+11, 0.100E+11
3, 0.100E+11, 0.000E+00, 0.100E+11, 0.100E+11
4, 0.100E+11, 0.000E+00, 0.100E+11, 0.100E+11
5, 0.100E+11, 0.000E+00, 0.100E+11, 0.100E+11
6, 0.100E+11, 0.000E+00, 0.100E+11, 0.100E+11
7, 0.100E+11, 0.000E+00, 0.100E+11, 0.100E+11
8, 0.100E+11, 0.000E+00, 0.100E+11, 0.100E+11
There is more to the file below this with varying row #'s - meaning no fixed row #'s or pattern
What I need is to be able to do is essentially copy the part that starts with Component and then include all the lines below it up to a textbox defined value +1 eg:
D = Val(SimulationsTextBox.Text) +1 (the simulations text box will always be different so I need to have this variable as part of the pattern recognition and this is already defined elsewhere)
and in the above example the simulations text box value is 8 so it copies 9 lines total starting with Component
Unfortunately this value will always change and I cannot use the standard import file, plus the file is very large so I cannot copy all the file starting with Component then delete the rows I do not need- I just need those 9 lines in this example.
I already know how to open the file and/or read it. I am just looking for the code for the pattern that lets me highlight the desired section and import them into cell A1 of sheet 2 in the already open excel file.
Please describe what each line of code does because I am a beginner at VB and Excel Macro coding.
Once that selection is imported into excel I would like to split it up into separate cells using comma delineated method.
Due to large file size, listing the fastest way for VB to execute this would be greatly appreciated.
Thanks,
Jeremy