I have an app that creates 3 reports: Income, Expense, and Budget. Each has 2 buttons (1 for line, 1 for columns) that calls macro1 with parameters. Each report is \displayed on separate sheets. The buttons are customUI ribbon buttons, but I don't think that matters because they all just call the macro1.
Macro1 (721 lines) creates a chart then calls Macro2 (436 lines) with several parameters to create a tale below the chart. There is a lot of shared logic, thus just using the 2 macros.
My issue is with macro2. The first time it runs for the Income Report, it misses an entire block of code. Subsequent runs are fine. Unless I run one of the other reports and then rerun the Income Report, which will then again miss the same code. The other reports run flawlessly.
On the first run, I get the first data set only, with the totals row directly below summing what is in the 1st 4 rows. Clicking the same button again with no data changes gets the expected all 3 data subsets. However, if I put a breakpoint just about anywhere before the block that gets missed, and then F5 it, I get all the data I am expecting on the first run. If I duplicate the macro2 call at the end of macro1 for the Income Report, I get the proper results.
I have run VBA Code Cleaner 5.0 on it. I have built in delays. I was experiencing some unexplainable intermittent crashes with the ribbon as well. So I have also created a new WB copying all the sheets and code files to it, with no resolution. Although it seems as though the ribbon issues have gone away for now. Any ideas of what else I can try? I could certainly separate macro2 into 3 subs, but prefer the code proficiency if possible. I have been at this for hours and was hoping someone else had experienced something like this?
Macro1 (721 lines) creates a chart then calls Macro2 (436 lines) with several parameters to create a tale below the chart. There is a lot of shared logic, thus just using the 2 macros.
My issue is with macro2. The first time it runs for the Income Report, it misses an entire block of code. Subsequent runs are fine. Unless I run one of the other reports and then rerun the Income Report, which will then again miss the same code. The other reports run flawlessly.
VBA Code:
'wsName is passes as a parameter from macro1
'Header created
'Create rows for data subset 1 (4 rows)
'this is the part that gets missed on the first run
Case wsName = "Income Report" (this the only report that gets the additional 2 subsets)
'add rows for data subset 2 (3 rows)
'add rows for data subset 3 (2 rows)
Case wsName = "Expense Report"
...
End Select
'create and format totals row
On the first run, I get the first data set only, with the totals row directly below summing what is in the 1st 4 rows. Clicking the same button again with no data changes gets the expected all 3 data subsets. However, if I put a breakpoint just about anywhere before the block that gets missed, and then F5 it, I get all the data I am expecting on the first run. If I duplicate the macro2 call at the end of macro1 for the Income Report, I get the proper results.
I have run VBA Code Cleaner 5.0 on it. I have built in delays. I was experiencing some unexplainable intermittent crashes with the ribbon as well. So I have also created a new WB copying all the sheets and code files to it, with no resolution. Although it seems as though the ribbon issues have gone away for now. Any ideas of what else I can try? I could certainly separate macro2 into 3 subs, but prefer the code proficiency if possible. I have been at this for hours and was hoping someone else had experienced something like this?