VBA stopping w/ no Error?

EdE

Board Regular
Joined
Apr 8, 2002
Messages
241
Does anyone know why a VBA would stop with out an error? It just runs and then stops in the middle of what it is doing? Here is the code:
If Range("c18").Value Then
Application.ScreenUpdating = False
Workbooks.Open FileName:= _
"\serverfolderMaterialsJimFJim.xls", _
UpdateLinks:=3, WriteResPassword:="jim"
'check to see if read only
If ActiveWorkbook.ReadOnly Then
ActiveWorkbook.Saved = True
ActiveWorkbook.Close
Range("e18").Select
Application.ScreenUpdating = True
ActiveCell.FormulaR1C1 = "Not Updated"
GoTo lastlinejim:
End If
'update file
Range("a1").Select
ActiveWorkbook.Save
ActiveWindow.Close
Range("i18").Select
ActiveCell.FormulaR1C1 = "Updated"
Application.ScreenUpdating = True
lastlinejim:
Range("a1").Select

End If
'displayed if not selected
If Range("c18") <> "True" Then
Range("e18").Select
ActiveCell.FormulaR1C1 = "Not Selected"
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Perhaps you may need to clarify what it is that you're asking.

Is it raising an error? If it isn't, one way code stops running without an error is that there are no errors in the code. (this is the aim of every programmer :biggrin: )

Is the code just crapping out and not letting you debug?
 
Upvote 0
Nope it just stops. It runs along and then just quits in the middle of the process. What is weird is that it doesnt do it on my other machine. But I have this problem on the machines of the people I did this for too. It is just one file in a list that this is a part of. If I have selections made after it, it doesnt go on to those. Any ideas?
 
Upvote 0
Any idea which line it stops at?

You can step through the code one line at a time.

Got to the VBE.
Right click on a toolbar at the top, choose Debug.
Go to the sub with this code in it and put the cursor somewhere in the code.
On the Debug toolbar, hit the "Step Into" button (button beside the hand) to run the code one line at a time.

Do this and you'll find out which line of code it craps out on.
 
Upvote 0
It is stopping just after 'update file.

I tried the stepping through and it went all the way through. Is this maybe just a flukey thing? Now its not doing it all the time. Oh crap.
This message was edited by EdE on 2002-05-07 11:11
 
Upvote 0
Is the workbook always read only? If it's read only, you're effectively telling the macro to end by sending it to the label "lastlinejim".

Are you open to suggestions for "improving" the code?
 
Upvote 0
It is never read only because you need to enter passwords to even open. I am having this problem on several versions of this, that is I created a template for ease of use to other programs. But I never had a problem with this until yesterday. Any improvement suggestions would be welcomed for sure!!

Thanks!
 
Upvote 0
Why have this line if it's never Read Only?

<pre>If ActiveWorkbook.ReadOnly Then </pre>

I'll have a better look at this tomorrow, but it seems like you only need about 5 lines of code. Code you tell me exactly what this code is supposed to be?
 
Upvote 0
Sorry Mark. I shouldnt have said it is never read only. It is supposed to just open the file to update links and then closes. If it is opened as read only, it skips to the end and goes on to the next one. Any guesses?
This message was edited by EdE on 2002-05-10 09:32
 
Upvote 0
I don't understand this bit of code from your original post:<pre>
'displayed if not selected
If Range("c18")<> "True" Then
Range("e18").Select
ActiveCell.FormulaR1C1 = "Not Selected"</pre>

Is this in another subroutine or something?

EDIT:: Scratch that, never mind, I just can't read.
_________________<font color = green> Mark O'Brien
This message was edited by Mark O'Brien on 2002-05-10 09:11
 
Upvote 0

Forum statistics

Threads
1,213,536
Messages
6,114,205
Members
448,554
Latest member
Gleisner2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top