Need help with loop to rename a folder

melodramatic

Board Regular
Joined
Apr 28, 2003
Messages
187
Office Version
  1. 365
Platform
  1. Windows
I am trying to run a macro that will go thru all of my project folders, renaming a specific sub-folder.

My loop so far works great! That is, if you don't mind doing anything more than changing out the count of the loop. What I need is the actual language that will run the folder rename for me.

Here's what I have:

Sub FinalDisposition()

'This routing will loop thru all the numbered project folders, changing the "5_Shipping" folder to "5_Final_Disposition"
'Cell A1 - how many times to run loop
'Cell A2 - how many times loop has already run
'Cell A3 - which loop is being run now (calculation is A2+1)
'Cell A4 - PN (figured by a calculated based on Cell A3)
'Cell A5 - root folder for PN (figured by a calculation based on Cell A4)

Dim FinalDisp As Long
For FinalDisp = 1 To Range("A1")

Dim LastRun As Long
Dim RunNow As Long
Dim RootFolder As String
Dim OldFolder As String
Dim NewFolder As String

LastRun = Range("A2")
RunNow = Range("A3")
RootFolder = Range("A5")
OldFolder = "5_Shipping"
NewFolder = "5_Final_Disposition"

' Name RootFolder & OldFolder As RootFolder & NewFolder

Range("A2").Select
ActiveCell.FormulaR1C1 = RunNow

Next FinalDisp

End Sub




Any help you could give me would be great!
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
might I suggest BULK FILE RENAMER, it can directory rename by pattern, its quick and accurate. Its not excel or even microsoft
 
Upvote 0

Forum statistics

Threads
1,222,312
Messages
6,165,276
Members
451,949
Latest member
bovacik

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