strange vba break

G

greg

I have a very strange scenario.
I am developing a xla for excel.
The first time I open up excel and run the xla, it breaks on one specific
line.
I can press run and it goes to the end.
The next time (and every other time) I run the xla, it does not stop.
There is no breakpoint on that line.
I have even rebooted. open excel. and run the xla. and it stops in the
same place.
The sub has an on error goto, so it is not the break on unhandled errors.
But it also only stops the first time opening excel. so I don't think this
is the reason.

Anyone have any ideas on how to stop this from happening?
thanks
 
T

Tim Williams

Check you don't have "break on all errors" set in the VBE.

Tools > Options > General

Or comment out the error handler to see if it raises an error.

Or post your code.

Tim
 
G

greg

So this is basically the code. I bit chunked out.
it stops on the the iMainLoop line. So strange.

I have break on unhandled errors.
thanks

----------------------------------
Sub LoadJoinedTable()
On Error GoTo PlannerError

Dim JoinedTable As Range
Dim iMainLoop As Integer

Dim objWS As Worksheet
Set objWS = Worksheets(WKSHT_JOINED_TABLE)

Set JoinedTable = objWS.Range(RANGE_JT_JOINED_TABLE)
objWS.Range(RANGE_JT_JOINED_TABLE).Worksheet.Activate

For iMainLoop = 1 To JoinedTable.Rows.Count
 
T

Tim Williams

What happens if you remove the error handler?

You might try fully qualifying all of your sheet references by including the
workbook

Eg:
Set objWS = ThisWorkbook.Worksheets(WKSHT_JOINED_TABLE)
instead of
Set objWS = Worksheets(WKSHT_JOINED_TABLE)

With multiple workbooks open the results using unqualified references can
sometimes be unpredictable.

Tim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top