form will not show when VBE is modified

bigt95nt

New Member
Joined
Apr 11, 2011
Messages
26
When the following code is executed, the form that the controls (CheckBoxes 1 to n) are created on fails to "Show" on the sheet. However the form appears in the project window with the correct number CheckBox Controls and if "RUN FORM" is selected the form apears on the sheet and each control works properly when each CheckBox is selected.

If on the other hand, if the code is commented out, the form displays on the sheet with the correct number of CheckBox controls, but no functionality
NOTE: the code shown is in a FOR NEXT loop and is not shown in its entirity.

Any comment would be greatly appreciated!

With TempForm.CodeModule
Line = .CountOfLines
.InsertLines Line + 1, "Sub Checkbox" & i & "_Change()"
.InsertLines Line + 2, " if ActiveChart.SeriesCollection(" & i & ").Format.Line.visible = True then"
.InsertLines Line + 3, ""
.InsertLines Line + 4, "ActiveChart.SeriesCollection(" & i & ").Format.Line.visible= False"
.InsertLines Line + 5, "exit sub"
.InsertLines Line + 6, "else ActiveChart.SeriesCollection(" & i & ").Format.Line.visible= True"
.InsertLines Line + 7, ""
.InsertLines Line + 8, "exit sub"
.InsertLines Line + 9, "end if"
.InsertLines Line + 10, "End Sub"
End With
 
Using a class shouldn't add any complexity.

There might be another option - a listbox with it's properties set to display a checkbox for each item.
 
Upvote 0

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Hey Folks there is something else I noticed about effects of this code. The entire program in a nutshell consists of a chart being created programacticly that displays 1 to n Series of data containing 1 to n datapoints in each. There are four buttons on the chart.

1 <CLOSE Window>decreases the number of points visible on the chart at any one time.

2 <OPEN Window>increaces the number of points visible on the chart at any one time.

3 <SHIFT Window Right>Shifts Window to the Right along the entire range of data points.

4 <SHIFT Window Left>Shifts Window to the Left along the entire range of data points.

All of these function depend on indicies that point to entries into associated ranges.

When the code below is executed not only does the UserForm fail to be displayed, but all of the varriables that keep track of what datapoints are being displayed on the chart go out of scope. I any of the 4 functions are run you get "Subscripts out of range." If the code is "Commented Out" then every works fine. The UserForm displays correctly with the correct number of CheckBoxes, and the above four functions function properly.

I would appreciate any comments!

This module can be found its entirty in eariler post in this thread
PS forgive the spelling


With TempForm.CodeModule
Line = .CountOfLines
.InsertLines Line + 1, "Sub Checkbox" & i & "_Change()"
.InsertLines Line + 2, " if ActiveChart.SeriesCollection(" & i & ").Format.Line.visible = True then"
.InsertLines Line + 3, ""
.InsertLines Line + 4, "ActiveChart.SeriesCollection(" & i & ").Format.Line.visible= False"
.InsertLines Line + 5, "exit sub"
.InsertLines Line + 6, "else ActiveChart.SeriesCollection(" & i & ").Format.Line.visible= True"
.InsertLines Line + 7, ""
" .InsertLines Line + 8, "exit sub"
.InsertLines Line + 9, "end if"
.InsertLines Line + 10, "End Sub"
End With
 
Upvote 0

Forum statistics

Threads
1,224,612
Messages
6,179,887
Members
452,948
Latest member
Dupuhini

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top