0

I have a list of files on Column A and i need to copy each file into the directory that is in column B. So i am looking for a macro that loops through column a and copies the file to the folder in column B

Column A

\192.168.2.13\path\file.pdf

\192.168.2.13\path\file2.xls

\192.168.2.13\path\file3.doc

Column B

\192.168.2.13\path\folder1

\192.168.2.13\path\folder2

\192.168.2.13\path\folder3

Any help would be appreciated!!

Ralph
  • 9,284
  • 4
  • 32
  • 42

2 Answers2

0

Here is what you should do with a pseudo-VBA code:

Read the files in column A and save them in array (AA).
Read the files in column B and save them in array (BB).

for each value in AA do the following:
    copy the value from AA with a destination BB

Pretty much you have two main problems - how to read the files from a column and how to copy and save them to a given location. Good luck!

Vityata
  • 42,633
  • 8
  • 55
  • 100
0

This should get you started.

Sub filemove()
Dim From As String
Dim Dest As String

'Assuming A1/B1 have headers
Range("A2").Cells.Select
i = 0
From = ActiveCell.Value
On Error Resume Next

Do While From <> ""
From = ActiveCell.Offset(i).Value
Dest = ActiveCell.Offset(i, 1).Value
FileCopy From, Dest

i = i + 1
Loop

End Sub

In your column b, you will need to state the file name using this method.

Good luck