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

  • Thread starter Thread starter mrbarritt
  • Start date Start date
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?
 
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)
 
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
 
Do you have any error handling in your routine?
What setting do you have in the VBE under Tools > Options > General > Error
tracking ?

Tim
 
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.
 
Back
Top