VB Question

davidhall80

Well-known Member
Joined
Jul 8, 2006
Messages
663
I get a data dump of 70 text files each week. I then run a batch to combine them and open it up in excel. The only problem is some of the 70 files don't always come thorough. If I am supposed to have the following 6 txt files dumped into my drive each week.

david.txt
Sally.txt
Micheal.txt
Robin.txt
Jack.txt
Jill.txt

But only david.txt, Sally.txt, & Jill.txt come through. Can I write in VB to tell me that Micheal.txt, Robin.txt, & Jack.txt weren't part of my batch. Maybe a message box or something....Thanks in advance....The search of course would be on the names of the txt files in a folder called "Data Dump" on my desktop.
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Not really sure what you wanted though....
Code:
Sub test()
Dim myDir As String, e, msg As String
myDir = CreateObject(WScript.Shell").SpecialFolders("Desktop") & "\Data Dump\"
For Each e In Array("david","Sally","Micheal","Robin","Jack","Jill")
     If Dir(myDir & e & ".txt") = "" Then msg = msg & e & ".txt" & vbLf
Next
MsgBox IIf(Len(msg)>0, "Missing" & vbLf & msg, "All files are in the folder")
End Sub
 
Upvote 0
For this line of code....I'm getting this message "Compile Error: Expected: list separator or)"


myDir = CreateObject(WScript.Shell").SpecialFolders("Desktop") & "\Data Dump\"


Any ideas??
 
Upvote 0

Forum statistics

Threads
1,222,405
Messages
6,165,864
Members
451,988
Latest member
boo203

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top