This macro seemed to work with files sorted ALPHABETICALLY(not numerically)
which means that a file named 123456789_a.pdfwould come BEFORE a file named 
234_a.pdf
even though 234 is numerically less than 1234567891 is less than 2 
"alphabetically", and therefore 123456789 would come first.
see if you can implement this:
It moved 2067 files into 11 folders (200 in each of the first 10, 67 in the 
last)
(BTW: in one of my applications, I load the file SIZES of the files in a 
folder.Then, sort by SIZE in descending order.I then move the files as long as 
the folder SIZE is less than 600Mb.I use it to create archive CD's. (not all of 
our computers have dvd drives)


Sub Divide_folder()
    Dim fso, fldr, FileNm, FileColl
    Dim FolderName, NewFolder, FolderIndex As Integer
    Dim fCnt, cnt
    
    FolderName = "C:\test\" '(be sure folder name ends in "\")
    
    Set fso = CreateObject("Scripting.FileSystemObject")
    fCnt = 0
    FolderIndex = 1
    NewFolder = FolderName & "Folder_" & Format(FolderIndex, "000") & "\"
    If (Not fso.folderexists(NewFolder)) Then
        MkDir NewFolder
    End If
    Set fldr = fso.GetFolder(FolderName)
'    Debug.Assert False
    For Each FileNm In fldr.Files
        Debug.Assert True
        fCnt = fCnt + 1
        If (fCnt > 200) Then
            FolderIndex = FolderIndex + 1
            NewFolder = FolderName & "Folder_" & Format(FolderIndex, "000") & 
"\"
            If (Not fso.folderexists(NewFolder)) Then
                MkDir NewFolder
            End If
            fCnt = 1
        End If
        fso.movefile FolderName & FileNm.Name, NewFolder
    
    Next FileNm
    MsgBox "Finished"
End Sub
 Paul-----------------------------------------
“Do all the good you can,
By all the means you can,
In all the ways you can,
In all the places you can,
At all the times you can,
To all the people you can,
As long as ever you can.” - John Wesley
-----------------------------------------
 
      From: Devendra Sahay <devendrasahanypt...@gmail.com>
 To: excel-macros@googlegroups.com 
 Sent: Tuesday, December 1, 2015 11:28 AM
 Subject: Re: $$Excel-Macros$$ Get files in a New folder with help of Macro
   
I am taking classes of VBA & macros. So  i can modify the macro. I have a one 
more question, will the macro short files in order and move them in folders.If 
it will work then please write & share.☺☺

On Dec 1, 2015 9:52 PM, "Paul Schreiner" <schreiner_p...@att.net> wrote:

Absolutely no problem.
In fact, you don't even have to use the batch file.
Excel macros have a FileSystem object that can be used to search through the 
folder.
How much do you know about macros?
If I were write a macro that took the list of files in a folder and created a 
folder:Folder_001and moved the first 200 files into it,then created Folder_002 
and moved the next 200 filesand so forth until all files were moved..
would you be able to follow the macro and modify it to fit what you REALLY 
want? Paul-----------------------------------------
“Do all the good you can,
By all the means you can,
In all the ways you can,
In all the places you can,
At all the times you can,
To all the people you can,
As long as ever you can.” - John Wesley
-----------------------------------------
 
      From: Devendra Sahay <devendrasahanypt...@gmail.com>
 To: excel-macros@googlegroups.com 
 Sent: Tuesday, December 1, 2015 11:18 AM
 Subject: Re: $$Excel-Macros$$ Get files in a New folder with help of Macro
   
Hi Paul,I am using a batch file to get the names of files in folder and then I 
want to move a batch of files( It may be a count of files) in a new folder.I 
have a condition suppose i have 2000 files in a folder and i have to make batch 
of 200 or more files. Right now am selecting files manually and moving them in 
a new folder. It means i have to make 10 batch and folder manuallySo if you can 
do it With a macro please help me.


On Dec 1, 2015 9:30 PM, "Paul Schreiner" <schreiner_p...@att.net> wrote:

I think you're using terms that do not have the same meaning to ME as they do 
to you.
I think you're saying:- You have a folder with some files.- In excel, you HAVE 
a list of the files in the folder.
You said you want to "extract these files".to ME, that means you wish to open 
the files and collect some data from each file (data extraction)But then you 
said: "in a new folder".
Are you saying that you want to move (or copy) the files that are in your excel 
list from one folder to another?
If so, it's easily done.
If not, then I'll need to know what you actually wish to do.
 Paul-----------------------------------------
“Do all the good you can,
By all the means you can,
In all the ways you can,
In all the places you can,
At all the times you can,
To all the people you can,
As long as ever you can.” - John Wesley
-----------------------------------------
 
      From: Devendra Sahay <devendrasahanypt...@gmail.com>
 To: excel-macros@googlegroups.com 
 Sent: Tuesday, December 1, 2015 5:16 AM
 Subject: $$Excel-Macros$$ Get files in a New folder with help of Macro
   
Hi Experts,

I have a excel sheet of files names, which are in a folder & I want to extract 
these files (which i have in excel sheet) in a new folder with the help of a 
macro.

Please help me out.


-- 

With Regard !!!Devendra Rahi

-- 
Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s 
=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ 
https://www.facebook.com/discussexcel
 
FORUM RULES
 
1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.
2) Don't post a question in the thread of another member.
3) Don't post questions regarding breaking or bypassing any security measure.
4) Acknowledge the responses you receive, good or bad.
5) Jobs posting is not allowed.
6) Sharing copyrighted material and their links is not allowed.
 
NOTE : Don't ever post confidential data in a workbook. Forum owners and 
members are not responsible for any loss.
--- 
You received this message because you are subscribed to the Google Groups "MS 
EXCEL AND VBA MACROS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to excel-macros+unsubscr...@googlegroups.com.
To post to this group, send email to excel-macros@googlegroups.com.
Visit this group at http://groups.google.com/group/excel-macros.
For more options, visit https://groups.google.com/d/optout.

-- 
Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s 
=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ 
https://www.facebook.com/discussexcel
 
FORUM RULES
 
1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.
2) Don't post a question in the thread of another member.
3) Don't post questions regarding breaking or bypassing any security measure.
4) Acknowledge the responses you receive, good or bad.
5) Jobs posting is not allowed.
6) Sharing copyrighted material and their links is not allowed.
 
NOTE : Don't ever post confidential data in a workbook. Forum owners and 
members are not responsible for any loss.
--- 
You received this message because you are subscribed to the Google Groups "MS 
EXCEL AND VBA MACROS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to excel-macros+unsubscr...@googlegroups.com.
To post to this group, send email to excel-macros@googlegroups.com.
Visit this group at http://groups.google.com/group/excel-macros.
For more options, visit https://groups.google.com/d/optout.


   
-- 
Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s 
=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ 
https://www.facebook.com/discussexcel
 
FORUM RULES
 
1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.
2) Don't post a question in the thread of another member.
3) Don't post questions regarding breaking or bypassing any security measure.
4) Acknowledge the responses you receive, good or bad.
5) Jobs posting is not allowed.
6) Sharing copyrighted material and their links is not allowed.
 
NOTE : Don't ever post confidential data in a workbook. Forum owners and 
members are not responsible for any loss.
--- 
You received this message because you are subscribed to the Google Groups "MS 
EXCEL AND VBA MACROS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to excel-macros+unsubscr...@googlegroups.com.
To post to this group, send email to excel-macros@googlegroups.com.
Visit this group at http://groups.google.com/group/excel-macros.
For more options, visit https://groups.google.com/d/optout.

-- 
Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s 
=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ 
https://www.facebook.com/discussexcel
 
FORUM RULES
 
1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.
2) Don't post a question in the thread of another member.
3) Don't post questions regarding breaking or bypassing any security measure.
4) Acknowledge the responses you receive, good or bad.
5) Jobs posting is not allowed.
6) Sharing copyrighted material and their links is not allowed.
 
NOTE : Don't ever post confidential data in a workbook. Forum owners and 
members are not responsible for any loss.
--- 
You received this message because you are subscribed to the Google Groups "MS 
EXCEL AND VBA MACROS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to excel-macros+unsubscr...@googlegroups.com.
To post to this group, send email to excel-macros@googlegroups.com.
Visit this group at http://groups.google.com/group/excel-macros.
For more options, visit https://groups.google.com/d/optout.


   
-- 
Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s 
=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ 
https://www.facebook.com/discussexcel
 
FORUM RULES
 
1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.
2) Don't post a question in the thread of another member.
3) Don't post questions regarding breaking or bypassing any security measure.
4) Acknowledge the responses you receive, good or bad.
5) Jobs posting is not allowed.
6) Sharing copyrighted material and their links is not allowed.
 
NOTE : Don't ever post confidential data in a workbook. Forum owners and 
members are not responsible for any loss.
--- 
You received this message because you are subscribed to the Google Groups "MS 
EXCEL AND VBA MACROS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to excel-macros+unsubscr...@googlegroups.com.
To post to this group, send email to excel-macros@googlegroups.com.
Visit this group at http://groups.google.com/group/excel-macros.
For more options, visit https://groups.google.com/d/optout.

-- 
Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s 
=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ 
https://www.facebook.com/discussexcel
 
FORUM RULES
 
1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.
2) Don't post a question in the thread of another member.
3) Don't post questions regarding breaking or bypassing any security measure.
4) Acknowledge the responses you receive, good or bad.
5) Jobs posting is not allowed.
6) Sharing copyrighted material and their links is not allowed.
 
NOTE : Don't ever post confidential data in a workbook. Forum owners and 
members are not responsible for any loss.
--- 
You received this message because you are subscribed to the Google Groups "MS 
EXCEL AND VBA MACROS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to excel-macros+unsubscr...@googlegroups.com.
To post to this group, send email to excel-macros@googlegroups.com.
Visit this group at http://groups.google.com/group/excel-macros.
For more options, visit https://groups.google.com/d/optout.


   

-- 
Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s 
=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ 
https://www.facebook.com/discussexcel

FORUM RULES

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.
2) Don't post a question in the thread of another member.
3) Don't post questions regarding breaking or bypassing any security measure.
4) Acknowledge the responses you receive, good or bad.
5) Jobs posting is not allowed.
6) Sharing copyrighted material and their links is not allowed.

NOTE  : Don't ever post confidential data in a workbook. Forum owners and 
members are not responsible for any loss.
--- 
You received this message because you are subscribed to the Google Groups "MS 
EXCEL AND VBA MACROS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to excel-macros+unsubscr...@googlegroups.com.
To post to this group, send email to excel-macros@googlegroups.com.
Visit this group at http://groups.google.com/group/excel-macros.
For more options, visit https://groups.google.com/d/optout.

Reply via email to