LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default It works when I step through it but it won't run

Hello Everyone,

I have a Sub in an add-in which when called (via a keyboard shortcut
CTRL+SHIFT+G) opens an existing workbook, gets some data out of it and
puts that data on the sheet. The function is driven by data in the
comment of the Activecell. Now it works when I step through it, it
works when I run through it (ie hit F5), (presuming in both cases the
activecell is the correct one) but it will not execute properly in
response to the keyboard shortcut. It stops after opening the existing
workbook. Here is the offending code:

For k = 1 To UBound(s, 1)
Set wbk = Application.Workbooks.Open(fileName:=s(k), AddtoMru:=False,
IgnoreReadOnlyRecommended:=True)
If (wbk Is Nothing) Then Err.Raise vbError + 2001, FUNCTION_NAME,
"Unable to open correlation source."
i = j
With wbk
..IsAddin = True
While (vToGet(i, 3) = s(k))
vToGet(i, 6) = wbk.Sheets("grid").Range(oMyTx.getAsXLColumn(vToGe t(i,
5) + 2) & CStr(vToGet(i, 4))).Value
i = i + 1
Wend
subscriptStart:
j = i - 1
End With
wbk.Close SaveChanges:=False
Set wbk = Nothing
Next k

wbk is declared: Dim wbk as Workbook

I don't know if a reference to wbk is ever set, it seems like it isn't
but I can't tell why. When execution stops, the workbook (ie s(k) in
the above code) is open and active and when I press ALT + F11 to go
into the debugger it is sometimes in design mode and sometimes not.

Can anyone shed any light on this problem.

Thanks everyone,

chilli

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro Works but not in Debug Step mode Bob Smedley[_2_] Excel Programming 3 January 31st 06 04:28 PM
macro works differently when using the Step Into (F8) feature Dave Y[_4_] Excel Programming 1 June 24th 05 03:06 AM
My VBA code works in the step though mode but not at full speed Nicole B Excel Programming 5 April 16th 05 02:54 AM
My VBA code works in the step though mode but not at full speed keepITcool Excel Programming 0 April 14th 05 12:54 AM
Works if I single step -\) Excel Programming 3 December 7th 04 04:24 PM


All times are GMT +1. The time now is 01:42 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"