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

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
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,224,823
Messages
6,181,182
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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