gururaj1986
New Member
- Joined
- Mar 14, 2017
- Messages
- 11
Hi All,
I am a beginner in VBA & currently working on a project where I need to open a few files files & paste the data from there to one master file (respective sheets) so that a template runs in the master file picking up values from each of these sheets. However there are certain cases where all 5 files are not required. So I wanted to know how can I add a code that can skip to the next file if there is an error in opening file. Below is an example of how the code looks:
Please do help out
Thanks, Guru
I am a beginner in VBA & currently working on a project where I need to open a few files files & paste the data from there to one master file (respective sheets) so that a template runs in the master file picking up values from each of these sheets. However there are certain cases where all 5 files are not required. So I wanted to know how can I add a code that can skip to the next file if there is an error in opening file. Below is an example of how the code looks:
Rich (BB code):
ThisWorkbook.Activate
Strfile = Sheet1.Range("M3").Value
'need to add a code here that can skip to first line of next code i.e thisworkbook.activate'
Workbooks.Open Filename:=Strfile
Range("A1:M150").Copy
wbaudit.Activate
Sheets("IMO EMV Holding").Activate
Range("A1").PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Workbooks.Open Filename:=Strfile
ActiveWorkbook.Close
ThisWorkbook.Activate
Strfile = Sheet1.Range("M4").Value
Workbooks.Open Filename:=Strfile
Range("A1:S90").Copy
wbaudit.Activate
Sheets("Perf & Risk Summary").Activate
Range("A1").PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Workbooks.Open Filename:=Strfile
ActiveWorkbook.Close
Please do help out

Thanks, Guru