Hi, Hoping someone can help here, Ive got quite a major hassle and been searching for an answer for some weeks, (it may be because I am using the wrong keywords so apologise if this is trivial)!
I have 40 tests that are done on a piece of equipment, but not every test is done each time. I want to check those tests I want to do using a checkbox on a form (and paste them one on top of the other in a single worksheet), but also have the ability to get rid of tests I may have ticked inadvertently. However I do not know of any way to reference the name of the checkbox in a subroutine. i.e. how do you address a particular checkbox using a function?
in other words I would like to see whether the value in Checkbox1 is ticked or not by using one function and changing the relevant variables to check others. Obviously I have 40 checkboxes; I dont want 40 different version of the above function such as:
I hope Ive made the problem clear
Greg
I have 40 tests that are done on a piece of equipment, but not every test is done each time. I want to check those tests I want to do using a checkbox on a form (and paste them one on top of the other in a single worksheet), but also have the ability to get rid of tests I may have ticked inadvertently. However I do not know of any way to reference the name of the checkbox in a subroutine. i.e. how do you address a particular checkbox using a function?
Code:
Dim ButtonName As CheckBox
ButtonName = "Checkbox1"
Call Function(ButtonName)
Sub Function(ByRef ButtonName As CheckBox)
If UserForm.ButtonName.Value = True Then
do something
End Sub
in other words I would like to see whether the value in Checkbox1 is ticked or not by using one function and changing the relevant variables to check others. Obviously I have 40 checkboxes; I dont want 40 different version of the above function such as:
Code:
Sub CheckBox1_Click()
If UserForm.CheckBox1.Value = True Then
do something
End Sub
Sub CheckBox2_Click()
If UserForm.CheckBox2.Value = True Then
do something
End Sub
I hope Ive made the problem clear
Greg