Consulting

Results 1 to 2 of 2

Thread: how to move xls files in same named folders by vba

  1. #1

    how to move xls files in same named folders by vba

    hi . how can i move excel files in same name folders by vba.
    for example
    i have abc.xls and " abc " folder .
    xyz.xls and " xyz " folder. i have number of xls files and want to move these files to same name folders

    I want to be done by vba

    heaps thanks in advance

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Dim filename As String, path As String, newdir As String
    
        path = "c:\Users\Bob\Downloads\"
        filename = Dir(path & "*.xl*", vbNormal)
        Do While filename <> ""
        
             newdir = Left$(filename, InStrRev(filename, ".") - 1) & Application.PathSeparator
             Name path & filename As newdir & filename
             filename = Dir()
        Loop
    Set path as required
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •