#1
|
|||
|
|||
Sorting File names
Dear All,
I get file names to an excel sheet from a folder, using the below macro. I tried to sort them in ascending order. but I have not sorted them in the correct order. please can anyone solve this issue? Correct oder : 1-1.pdf, 1-2.pdf, 1-3.pdf ............... 1-10.pdf, 1-11.pdf......1-20.pdf.. After getting to the excel sheet: 1-1.pdf, 1-10.pdf, 1-11.pdf, 1-20.pdf........ My VBA Code : Sub Get_Old_File_Name() Dim myPath As String Dim myFile As String Dim r As Long myPath = "C:\Users\User\Desktop\Maling Payadvice\NVQ\PaySlips" myFile = Dir(myPath & "*.*") If myFile = "" Then MsgBox " No Files in the Folder" Else r = 4 Do While myFile <> "" Cells(r, 5).Value = myFile r = r + 1 myFile = Dir Loop MsgBox "Completed" End If End Sub |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Sorting Names | LargeAllen | Word | 3 | 04-19-2017 11:42 PM |
How capture a folder's file names to a file? | BobKnepper | Word | 2 | 05-22-2016 07:30 AM |
Copy and Paste from File to File but File Names always change | aaronbauer1980 | Excel Programming | 1 | 04-15-2016 05:53 PM |
Problem sorting names alphabetically? | mikehende | Excel | 12 | 09-12-2012 12:00 PM |
Two Different Names in the Same File | kathy carson | Outlook | 0 | 02-14-2006 01:02 PM |