Hi Vasant,

I am trying to create a macro to do this below task to avoid manual efforts.
For more details please refer the below email.

Here is my code-

Sub Movefiles()
Dim a As Integer
Dim fso, f2
    With Application.FileSearch
        .LookIn = "C:\LLF\" & Range("A1").Value
        .FileType = msoFileTypeAllFiles
        .Execute
        MsgBox "Total Files Available is : " & (.FoundFiles.Count)

a = WorksheetFunction.Sum((.FoundFiles.Count) / 50)
If .FoundFiles.Count < 50 Then

On Error GoTo 1
MkDir "C:\Amrahs"  ' change the path and  name
MsgBox ("Folder Created")

Exit Sub
1 MsgBox ("Folder Already Exist!")
Else
If .FoundFiles.Count > 50 Then
Do While a <> 0
MkDir "C:\Target\Amrahs" & a
MsgBox ("Folder Created")
Loop
End If
End If
End With
End Sub

Am getting error message in the highlighted line. Also this code is only use
to create folders based on number of files available in the specified
folder. If the folder contains 500 files then it should be divided by a
constant number "50" and you will get 10. So 10 folders needs to be created.

Additonally while creating folders the code should move 50 files to the
first folder and the next 50 files to the second folder and so on. At last
all the 500 files should be moved to the respective 10 folders. If the file
count is 480 or >500 then the remaining files should be moved to the last
folder.

Please look into this and help me to overcome this issue since it is very
much required as every time am doing it manually.

Any idea or suggestion will be greatly appreciated.

Thanks a lot!
-Sharma

On Mon, Aug 30, 2010 at 12:36 PM, amrahs k <amrahs...@gmail.com> wrote:

> Dear Experts,
>
> I have a problem to work on a folder where in I need to do manually to do
> the below task.
>
> I have a folder named as "Calibration" in "C:" drive. It contains 500 excel
> files. What I want to do is to create new folder1 and move 50 files to it.
> Then another 50 files to new folder2 till the folder gets empty (i.e) all
> the files moved to new folder.
>
> Can we do it using VBA.
>
> Please suggest me to solve this issue.
>
> Regards,
> Sharma
>

-- 
----------------------------------------------------------------------------------
Some important links for excel users:
1. Follow us on TWITTER for tips tricks and links : 
http://twitter.com/exceldailytip
2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
3. Excel tutorials at http://www.excel-macros.blogspot.com
4. Learn VBA Macros at http://www.quickvba.blogspot.com
5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
 
To post to this group, send email to excel-macros@googlegroups.com

<><><><><><><><><><><><><><><><><><><><><><>
HELP US GROW !!

We reach over 7000 subscribers worldwide and receive many nice notes about the 
learning and support from the group.Let friends and co-workers know they can 
subscribe to group at http://groups.google.com/group/excel-macros/subscribe

Reply via email to