Move File from one directory to another based on 3rd column value

Adiba Qudoos

New Member
Joined
Mar 2, 2019
Messages
4
Hello everybody
I need to rename and move files from Folder A to Folder B based on some criteria

I have 3 column A, B, C
  1. Column A : contains "old/parent path"
  2. Column B : contain "new name of files"
  3. Column C : contains "new path "

I need a code of three parts
2 have been solved but at third i am stuck badly

2nd is
if column A.value is equal Column B.value then respective file from column B will be renamed only (no move).
3rd point is

if column A.value is not equal Column B.value then respective file from column B will be moved to Folder B (no rename only move).

anybody please help
 

Some videos you may like

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

Adiba Qudoos

New Member
Joined
Mar 2, 2019
Messages
4
For updating Column A, I have used a automated way using
Dim fnam As Variant
' fnam is an array of files returned from GetOpenFileName
' note that fnam is of type boolean if no array is returned.
' That is, if the user clicks on cancel in the file open dialog box, fnam is set to FALSE

Dim b As Integer 'counter for filname array
Dim b1 As Integer 'counter for finding \ in filename
Dim c As Integer 'extention marker

' format header
Range("A1").Select
ActiveCell.FormulaR1C1 = "Path and Filenames ( Old )"
Range("A1").Select
With Selection.Font
.Name = "Arial"
.FontStyle = "Bold"
.Size = 10
End With
Columns("A:A").EntireColumn.AutoFit
Range("b1").Select
ActiveCell.FormulaR1C1 = "Path and Filenames ( New )"
Range("b1").Select
With Selection.Font
.Name = "Arial"
.FontStyle = "Bold"
.Size = 10
End With
Columns("b:b").EntireColumn.AutoFit
Range("C1").Select
ActiveCell.FormulaR1C1 = "Input New Filenames Below"
Range("C1").Select
With Selection.Font
.Name = "Arial"
.FontStyle = "Bold"
.Size = 10
 

Watch MrExcel Video

Forum statistics

Threads
1,114,528
Messages
5,548,571
Members
410,852
Latest member
WernerS
Top