Let's say I have a list of file path in Excel column BD. How do I use VBA command to select all the file paths in column BD and save it to anywhere I want?
I couldn't find any tutorials on this.
This was the closest:
https://www.youtube.com/watch?v=pHFucY4VMT4
But I think this is restricted to excel and a specific file path.
Would appreciate any easy-to-use code advice here! New to VBA so please don't thrash me too badly :P
P.S I tried this but I am receiving an error:
Private Sub CommandButton8_Click()
Option Explicit
Sub CopyFiles()
' (1) requires a reference to the object library "Microsoft Scripting Runtime" under Options > Tools > References in the VBE.
Dim FSO As Scripting.FileSystemObject
Dim DesPath As String
Dim C As Range
Dim LastRow As Long
Set FSO = New Scripting.FileSystemObject
'your destination path
DesPath = "C:\"
With ThisWorkbook.Sheets("MySheet") 'change MySheet for your sheet name
LastRow = .Cells(.Rows.Count, "BD").End(xlUp).Row 'last row on column BD
For Each C In .Range("BD2:BD" & LastRow) 'loop through all the cells from 2 to LastRow
If Not C = vbNullString Then 'check that the cell isn't blank
FSO.CopyFile C.Value, DesPath, True 'True means overwrite
End If
Next C
End With
End Sub
The error message I received is "Compile error: Invalid inside procedure"
This error highlights in yellow this VBA command: "Private Sub CommandButton8_Click()"