Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
to convert all the file names in one directory to .xls? | Excel Discussion (Misc queries) | |||
Getting file names in a directory | Excel Programming | |||
Creating a macro that lists directory names within a directory.... | Excel Programming | |||
Aquiring Directory names | Excel Programming | |||
Aquiring Directory names | Excel Programming |