MACRO Error trying to Locating Files

nassr

New Member
Joined
Sep 8, 2006
Messages
11
I'm using the following code to create a macro that looks into various directories and files based on a specified list. The macro was working correctly yesterday, but now I keep getting an error message that says it cannot find the appropriate file (even though the file names are correct). Any ideas what I could do to fix?

Sub CreateGroupProcurementsFile()
' '
Application.ScreenUpdating = False

'create variable for user path and file
Dim MyPath
Dim MyFile

'Clear Old Data
GroupProcurement.Range("A7:T10000").Select
Selection.ClearContents

'start at first file
MACRO.Select
Range("A7").Select

'create loop for each file
Do Until ActiveCell = ""
Let MyPath = ActiveCell.Value
ActiveCell.Offset(0, 1).Range("A1").Select
Let MyFile = ActiveCell.Value
ChDir MyPath
Set wbOpen = Workbooks.Open(Filename:=MyFile, UpdateLinks:=0) 'This is the line that is continually getting caught up

'Copy and Paste Range file

Sheets("Plan").Select
Range("A51:T1200").Copy

Windows("GroupProcurements.xls").Activate
GroupProcurement.Select
Range("A65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Select

Selection.PasteSpecial Paste:=xlPasteValues

wbOpen.Close

'move down to next file
MACRO.Select
ActiveCell.Offset(0, -1).Range("A1").Select
ActiveCell.Offset(1, 0).Range("A1").Select
Loop
'end of loop above

GroupProcurement.Select
Range("A1").Select

End Sub
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.

Forum statistics

Threads
1,136,991
Messages
5,679,004
Members
419,797
Latest member
ikethegenius

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
Top