开发者

What is the Bug in the below code? [closed]

开发者 https://www.devze.com 2023-03-28 21:09 出处:网络
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clari开发者_如何学Gofy the problem by editing this post.
Closed. This question needs details or clarity. It is not currently accepting answers.

Want to improve this question? Add details and clari开发者_如何学Gofy the problem by editing this post.

Closed 9 years ago.

Improve this question

I have written

        sub main ()
        'some code goes here
        end sub

This is the Module that I defined in the sheet1.And Yes I have only one workbook opened and in the userform1 I have given a command button Ok and when ok is pressed , The main function in sheet1 should be called

 sub CommandButton1_Click()
    call sheet1.main
 end sub

I have tried these The problem Iam facing is , The code works sometimes and sometimes throws an error saying that an undefined object or not set with Occured.Why the code is working for sometimes and not for sometimes? Do i need to make any changes to make it work everytime ? Thank you in advance


The one thing I've found that makes my VBA programming easier is to always fully specify the object you're trying to manipulate (well, except maybe the top-level Application).

That means you should use something like Workbooks(0).Worksheets("Sheet1").main instead of relying on the active workbook.

0

精彩评论

暂无评论...
验证码 换一张
取 消