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

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
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,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

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