• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Progress Bar

Hi,

I am trying to create a progress bar for a code. The challenge is that there is no loop and its a sequence of steps. My idea was to calculate the progress based on the how many lines of code has been executed i.e. the line number of the active code / total number of lines.

I found that we can get the total number of lines using "Application.VBE.ActiveCodePane.CodeModule.CountofLines", but I am not able to get the line number of the active line. Hope this makes sense and there is some solution.

Regards
Prem
 
Hi Prem, and welcome to the forum.

I would strong advise against trying to access the VBE code pane with your macro. It's very unstable as the number of lines can easily change, and you can also run into security issues (macros have access to code page is a security concern). Instead, I would suggest that you pick the assigned value. So, determine that after such-and-such step, 25% complete, then later 50% complete, then 75%, then 100% at the end. It doesn't have to be precise, just enough to give your user feedback that something is still happening.

Ideally, you'd also want to have the code running fast enough that you don't need to see an increment at each percentage.
 
Luke,

Thanks for the response and explanation. I understand that it is not a very friendly code. This was for more of intellectual curiosity, if it is possible to do such an exercise. I looked around for this information a lot, and couldn't find. I have seen this being done in other programming languages. So was curious if it was possible..

Regards
Prem
 
Back
Top