Move files to "history" folder

Juleew

New Member
Joined
Nov 24, 2009
Messages
45
I am creating files based upon a database that is updated daily. Each time the file is updated I am moving the older version to a history folder. I don't want to move all files out of the folder just the ones that contain names that are NAMES_NEMS_ & "*.*". I am using the below code without success. I am trying to write code to determine that if there is no file then skip moving the file.

If Dir(\\server\dname\folder\NAMES_NEMS_) <> " " Then
Dim FSO As Object
Set FSO = CreateObject("scripting.filesystemobject")
FSO.movefile (\\server\dname\folder\NAMES_NEMS_ & "*.*"), HFP

Thanks for any help
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Not tested here but try:-
Code:
If Dir([B][COLOR=red]"[/COLOR][/B]\\server\dname\folder\NAMES_NEMS_[B][COLOR=red]*.*"[/COLOR][/B]) <> [COLOR=red][B]""[/B][/COLOR] Then
Dim FSO As Object
Set FSO = CreateObject("scripting.filesystemobject")
FSO.movefile([B][COLOR=red]"[/COLOR][/B]\\server\dname\folder\NAMES_NEMS_[COLOR=red][COLOR=black]*.*[/COLOR][B]"[/B][/COLOR])[COLOR=#000000], HFP
[/COLOR]
What's HFP? A string variable containing the name of a folder?
 
Upvote 0

Forum statistics

Threads
1,224,502
Messages
6,179,126
Members
452,890
Latest member
Nikhil Ramesh

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