Changing sheet codename Run-Time Error 9: Subscript out of range

前端 未结 4 1144
死守一世寂寞
死守一世寂寞 2021-01-12 02:19

I\'ve code which, when I press a button, will add a new sheet to a workbook and change the codename of the sheet to make it easier to refer to later in my code.



        
4条回答
  •  耶瑟儿~
    2021-01-12 03:07

    Another simple method to force refreshing of the VBComponents Collection:

    PropertyGetDiscard ThisWorkbook.VBProject.VBComponents.Count
    

     

    Private Sub PropertyGetDiscard(AnyPropertyGet): End Sub
    

    The procedure PropertyGetDiscard is used to avoid polluting the Immediate window or using a superfluous variable

提交回复
热议问题