Changing directory names
Thank you both very much! I'll go away and have a play!
Thanks again
Karen
"Norman Jones" wrote:
Hi Karen,
Assume the old folder names are in A2:A10 and the new names are in B2:B10,
Try:
'===============
Public Sub TryIt()
Dim rng As Range
Dim rcell As Range
Set rng = Range("A2:A10") '<<=== CHANGE
For Each rcell In rng.Cells
With rcell
If Not IsEmpty(.Value) Then
RenameFolder .Value, .Offset(0, 1).Value
End If
End With
Next rcell
End Sub
'<<===============
'===============
Public Function RenameFolder(sourceFolder As String, _
targetFolder As String)
On Error Resume Next
With CreateObject("Scripting.FileSystemObject")
.MoveFolder sourceFolder, targetFolder
End With
End Function
'<<===============
---
Regards,
Norman
"Karen Howie" wrote in message
...
Hi folks,
I'd like to write a macro which loops around a table in excel changing a
directory name (listed in one column) to another name (listed in a second
column). What is the command to change a directory name?
Thank-you!
Karen
|