Ark68
Well-known Member
- Joined
- Mar 23, 2004
- Messages
- 4,616
- Office Version
- 365
- 2016
- Platform
- Windows
So, imagine this.
I have a workspace on my worksheet ... liken it to a user form. Its a range of say A15:F25.
Within this workarea are a series of cells that appear/disappear based on a users input.
There are also objects that I assign macros to to act as navigation type buttons. This workarea is used for many different activities throughout my application, and is altered in "blocks" depending on the activity. It is never really static.
When I need to reset this work area, I have found it easiest to just remove all the objects with this code ...
And copy the default work area from another worksheet overtop the existing workarea. This ensures that the workarea is reset.
However, I have run into a problem.
At one point, my workarea has a merged cell with a list validation.
When I copy over the default range, everything seems OK.
However, when I apply the code to remove the objects, I get a "Run Time Error 1004, Application-defined or Object-defined error." in my object removal routine. It stops at TheLeft = PicObj.TopLeftCell.Address.
To observe the work area reveals rements of the merged cell with the validation list. It is no longer an active cell but it has a border around it with the little drop down arrow next to it.
I don't quite understand what it going on. That cell should have been reset with the copy of the default range which is supposed to elimate these fields.
Can anyone suggest what I can consider as a cause of this?
Jenn
I have a workspace on my worksheet ... liken it to a user form. Its a range of say A15:F25.
Within this workarea are a series of cells that appear/disappear based on a users input.
There are also objects that I assign macros to to act as navigation type buttons. This workarea is used for many different activities throughout my application, and is altered in "blocks" depending on the activity. It is never really static.
When I need to reset this work area, I have found it easiest to just remove all the objects with this code ...
Code:
For Each PicObj In .Shapes
TheLeft = PicObj.TopLeftCell.Address
Set isect = Application.Intersect(.Range(TheLeft), .Range("A15:F25"))
If Not isect Is Nothing Then PicObj.Delete
And copy the default work area from another worksheet overtop the existing workarea. This ensures that the workarea is reset.
However, I have run into a problem.
At one point, my workarea has a merged cell with a list validation.
When I copy over the default range, everything seems OK.
However, when I apply the code to remove the objects, I get a "Run Time Error 1004, Application-defined or Object-defined error." in my object removal routine. It stops at TheLeft = PicObj.TopLeftCell.Address.
To observe the work area reveals rements of the merged cell with the validation list. It is no longer an active cell but it has a border around it with the little drop down arrow next to it.
I don't quite understand what it going on. That cell should have been reset with the copy of the default range which is supposed to elimate these fields.
Can anyone suggest what I can consider as a cause of this?
Jenn