Meghanakusuma
New Member
- Joined
- Apr 10, 2018
- Messages
- 11
hi, please help me to find the error.
when i run this code, it says the path not found
when i run this code, it says the path not found
Code:
Public Sub process()
Application.DisplayAlerts = False
Application.ScreenUpdating = False
'DECLARE AND SET VARIABLES
reset
Dim wbk As Workbook
Dim Filename As String
Dim Path As String
Dim sheet_four As Worksheet
Dim sheet_five As Worksheet
Set sheet_four = ThisWorkbook.Worksheets("Sheet4 - Part List&Rel Data")
Set sheet_five = ThisWorkbook.Worksheets("Sheet5 - FMEA")
Application.FileDialog(msoFileDialogFolderPicker).Show
Path = Application.FileDialog(msoFileDialogFolderPicker).SelectedItems(1) & ""
'Path = Application.FileDialog(msoFileDialogFolderPicker)
'Path
'Path = "C:\Users\yatisha.arehally\Desktop\ALL Documents"
Filename = Dir(Path & "*.xls*")
'--------------------------------------------
'OPEN EXCEL FILES
Do While Filename <> "" 'IF NEXT FILE EXISTS THEN
Set wbk = Workbooks.Open(Path & Filename)
'
' CODE GOES HERE
'
ActiveWorkbook.Sheets(7).Select
lr4 = sheet_four.Cells(Rows.Count, 1).End(xlUp).Row
lr5 = sheet_five.Cells(Rows.Count, 1).End(xlUp).Row
lra = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
ActiveSheet.Range(Cells(7, 1), Cells(lra, 11)).Copy
sheet_four.Cells(lr4 + 1, 1).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveWorkbook.Sheets(8).Select
lrb = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
ActiveSheet.Range(Cells(8, 1), Cells(lrb, 16)).Copy
sheet_five.Cells(lr5 + 1, 1).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
'MsgBox Filename & " has opened"
wbk.Close True
Filename = Dir
Loop
Sheets(1).Select
MsgBox "Its done!"
Application.ScreenUpdating = True
Application.DisplayAlerts = False
End Sub
Sub reset()
For i = 1 To ActiveWorkbook.Sheets.Count
lri = Sheets(i).Cells(Rows.Count, 2).End(xlUp).Row
lci = Sheets(i).Cells(1, Columns.Count).End(xlToLeft).Column
If lri >= 2 Then
Sheets(i).Select
Range(Cells(2, 1), Cells(lri, lci)).Clear
End If
Next i
Sheets(1).Select
End Sub
Last edited by a moderator: