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
 

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
42,169
Office Version
365
Platform
Windows
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
 

Forum statistics

Threads
1,081,545
Messages
5,359,435
Members
400,528
Latest member
Ratish52

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top