largeselection
Active Member
- Joined
- Aug 4, 2008
- Messages
- 358
I have some code which basically consolidates all worksheets from a workbook into the first sheet. It has on error resume next so it can continue the code after consolidating. I need to add an error messagebox that appears if the code can't find the correct reference file open. How can I add this? I've tried a couple different constructions and none seem to work.
So I want a messagebox to say can't find reference and then exit the sub since it will mess up the file if it can't find that file. I've tried putting in an on error goto error1 which is a messagebox and exit sub, but then it just does that all the time.
Here is some of the code:
So I want a messagebox to say can't find reference and then exit the sub since it will mess up the file if it can't find that file. I've tried putting in an on error goto error1 which is a messagebox and exit sub, but then it just does that all the time.
Here is some of the code:
Code:
.
.
.
Dim J As Integer
Windows("Reference.xls").Activate
On Error Resume Next
Sheets(1).Select
For J = 2 To Sheets.Count
Sheets(J).Activate
Range("A1").Select
Selection.CurrentRegion.Select
Selection.Offset(4, 0).Resize(Selection.Rows.Count - 4).Select
Selection.Copy Destination:=Sheets(1).Range("B1048576").End(xlUp).Offset(1, -1)
Next
.
.
.