Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel Error Handling Query

Status
Not open for further replies.

JasonEnsor

Programmer
Sep 14, 2010
193
GB
Hi Guys,

A lot of my projects pass data between workbooks, however the project I am working on at the moment is possibly the worst for it. How can I ensure that if an error occurs the external workbook closes and my current workbook activates on the desired sheet? The issue is sometimes an error occurs in workbook x and then my application tries to access a range in workbook x as it is active but it should be looking for a range in workbook y which is where the macro is actually running. Error handling in VBA is quite new to me and so far I have gotten away without using it, but as my skills improve my projects are getting more complex and so I think it's time I start using error handling.

Any tips would be appreciated on how to tackle this one

Regards

Jason
 
Hi,

So you're not referring to a query that you are executing but it refers to a question?

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Sorry Skip, I worded that wrong. It's been a long day here. It is a question and not a data query that I am referring too.

Regards

Jason
 
it should be looking for a range in workbook y which is where the macro is actually running
Use ThisWorkbook instead of ActiveWorkbook

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top