How many lines of code can VBA run?

excelnoob001

New Member
Joined
Jul 24, 2019
Messages
26
When I run my code in debug mode, line by line, it works.

However, when I run it as a macro through a button, the macro stops abruptly
about 1/5 through the entire code.

Any ideas why this is happening?

Thank you.
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
For sure this is not because of a limit to the number of lines that can be run.

You need to find out why the conditions in your program are different when you step through it from how they are when you let it run unhindered by debug mode.

Try to put things in your code which tell you what's going on inside it.

I've been using "MsgBox" a lot just lately but like you I'm an Excel noob so there must be better ways. At least I hope there are. ;)

Try to avoid the trap that you have already fallen into. They call it "the XY problem" and I'll leave you to search for that.

Don't feel bad; we've all been there sometime.
 
Last edited:
Upvote 0
It would help if you posted your code, pointed out which line it fails on and what the error number & message is
 
Upvote 0
By any chance, is there a brown (or perhaps a different colour) round "blob" to the left of your code - in the margin - with the associated line of code highlighted the same colour? If so, this is a "Break" where code will stop running in automatic mode, but running line-by-line will overcome this, and carry on executing.
The break mode is used in fault finding...
 
Upvote 0

Forum statistics

Threads
1,214,998
Messages
6,122,643
Members
449,093
Latest member
Ahmad123098

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