Certain methods, such as Cells.EntireRow.Hidden, stop VBA subrouti

M

mrbarritt

I have been noticing that when using VBA in Excel, certain methods can cause
the termination of a subroutine without any warning. Some of these are:

Cells.EntireRow.Hidden
Range("O3:AQ3").MergeCells = False
Columns("AD").Insert Shift:=xlToRight, CopyOrigin:=Null

Has anyone else had a similiar experience or know why?
 
C

Chip Pearson

Are these lines of code being executed in a VBA procedure that is
directly or indirectly called from a worksheet cell? If so, that is
the problem. Code initiated by a worksheet cell cannot make any
changes to the Excel environment.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 
M

mrbarritt

Chip,
There are two cases for code initiation. One is a button control that I
have placed on a sheet, the other is a custom menu that I have added to the
menu bar. In either case the execution does not involve a worksheet cell.

Mark
 
T

Tim Williams

Do you have any error handling in your routine?
What setting do you have in the VBE under Tools > Options > General > Error
tracking ?

Tim
 
M

mrbarritt

For this routine, I do not have any custom error handling.

Error Tracking is set to "Break on Unhandled Errors"

Again, I get no indication that there has been an error, no msg box with the
run time error number etc. The procedure simply stops and does not execute
the next statement.
 

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