bs0d
Well-known Member
- Joined
- Dec 29, 2006
- Messages
- 622
I'm creating a custom function to cut down on redundant code. However, in converting the code to a function so that it may be used in different instances, I'm getting an unexpected error when the code executes.
The error is:
Here is my function:
The function checks the status of the checkbox name passed to it. If it's checked, it will show a chart series. If it's not checked, it will hide the chart series. The error comes in referencing the "checkboxName".
How might I need to alter the code so that I can use the form control name as a variable? This is ultimately one of the key components of the function as each control has it's own name.
Thanks
The error is:
Code:
Object doesn't support this property or method.
Here is my function:
Code:
Public Function chkClick(checkboxName As String, tabName As String, chartName As String, seriesNumber As Long)
Sheets(tabName).ChartObjects(chartName).Activate
If Sheets(tabName).checkboxName.Value = True Then
ActiveChart.FullSeriesCollection(seriesNumber).Select
With Selection.Format.Line
.Visible = msoTrue
End With
Else
ActiveChart.FullSeriesCollection(seriesNumber).Select
With Selection.Format.Line
.Visible = msoFalse
End With
End If
End Function
The function checks the status of the checkbox name passed to it. If it's checked, it will show a chart series. If it's not checked, it will hide the chart series. The error comes in referencing the "checkboxName".
How might I need to alter the code so that I can use the form control name as a variable? This is ultimately one of the key components of the function as each control has it's own name.
Thanks