Using Do loops to read files

Loulou2

New Member
Joined
Sep 14, 2005
Messages
6
Hi All,

I need my vba programme to import a series of 4 consecutively numbered files e.g. ....week1, ....week2 etc etc. I figure that I can use a do loop to do this, but am struggling with quite how. Can someone help me please?

Thanks,

Loulou
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Hi

You just need to have a FOR...NEXT loop that constructs your filename on the fly - e.g.

Code:
For counter = 1 to 5
Filename = "myfilename" & counter & ".txt"
...your import stuff here...
Next counter
Hope that helps
Martin
 
Upvote 0

Forum statistics

Threads
1,214,522
Messages
6,120,022
Members
448,939
Latest member
Leon Leenders

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