2017-03-16 24 views
0

我有列A上的文件列表,我需要將每個文件複製到列B中的目錄中。 所以我期待,通過柱和循環複製該文件到文件夾列BExcel宏將文件列(列A)複製到文件夾的特定列表(列b)

列A

\ 192.168.2.13 \路徑\ file.pdf

\ 192.168宏。 2.13 \ path \ file2.xls

\ 192.168.2.13 \ path \ file3.doc

列B

\ 192.168.2.13 \路徑\文件夾1

\ 192.168.2.13 \路徑\文件夾2

\ 192.168.2.13 \路徑\ folder3

任何幫助將是感謝!

回答

0

這裏是你應該用僞VBA代碼做什麼:

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 

差不多,你有兩個主要問題 - 如何從一列讀取這些文件,以及如何複製並保存到一個給定的位置。祝你好運!

0

這應該讓你開始。

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 

在列b中,您將需要使用此方法聲明文件名。

祝你好運

相關問題