Cycle through cells as filenames

Dendennydenden

New Member
Joined
Mar 5, 2018
Messages
7
Hi,

I hope someone can help with this.
i am trying to use VBA to import data from multiple csv files.
Column A contains a list of filenames (around 20 rows)
My current code goes to cell A3, uses that as its filename, copies information from the file and pastes it into cells B3:M3 of my 'master'.

Can someone advise me on how to then move down a row, repeat the copy/paste macro, and continue down until it finds a blank row in column A.

All help gratefully received.

Thanks
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Looks like a structure like this should do what you want
Rich (BB code):
Sub Process_Files()
  Dim fName As String
  Dim r As Long
  
  r = 3
  Do Until Len(Range("A" & r).Value) = 0
    fName = Range("A" & r).Value
    r = r + 1
    
    'Your existing code goes here, using the variable fName as the file name
  
  Loop
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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