Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I have made a list of option button. When I select a particular option, the excel should identify and delete the previous object names starting with "onstrfr". However, when it identifies the correct obj name "onstrfr", the obj.Delete gives "Run-time error '1004': Application-defined or object-defined error". I'll be grateful if someone can help me to solve this problem. Loy === FROM Sheet1======= Private Sub on3wdgtrfroption_Click() Call Sheet2.Deleteonstrfr Call Sheet2.OnshoreTrfr(myValue, 2) End Sub ===From Sheet2======== Sub Deleteonstrfr() Dim Obj As Object For Each Obj In ThisWorkbook.Sheets("SLD").Shapes If Left(Obj.Name, 7) = "onstrfr" Then MsgBox Obj.Name Obj.Delete End If Next Obj End Sub |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Personally I restrict the subs in a worksheet module to events related to the
worksheet. All other subs I put in a standard module. You might get some other views on this but I have seen lots of strange things occur when you put subs that are not really related to the specific worksheet in the worksheet module. Put the called routine (Sub Deleteonstrfr) in a standard module and try it. -- Regards, OssieMac |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks very much for your advice. The problem seems to go away after placing
the Subroutine in the standard Module. Best wishes, Loy "OssieMac" wrote: Personally I restrict the subs in a worksheet module to events related to the worksheet. All other subs I put in a standard module. You might get some other views on this but I have seen lots of strange things occur when you put subs that are not really related to the specific worksheet in the worksheet module. Put the called routine (Sub Deleteonstrfr) in a standard module and try it. -- Regards, OssieMac |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Selecting objects for deletion in 2007 | Excel Discussion (Misc queries) | |||
setting error handling on control creation and deletion | Excel Programming | |||
Cannot shift objects error | Excel Discussion (Misc queries) | |||
Get objects property names in run-time? | Excel Programming | |||
Run-time error '1004' running to excel objects at once | Excel Programming |