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
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
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
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top