WallIT
01-16-2013, 08:36 AM
Hi,
I have a simple userform with 4 checkboxes. In my example the values of these are set to colors:
checkbox1.value = "blue"
checkbox2.value = "red"
checkbox3.value = "green"
checkbox4.value = "yellow"
The user has to select at least one checkbox, but can select more than one, up to all 4 checkboxes.
If the user checks a single box, such as checkbox1, then then my code updates a bookmark to the value, in this case 'blue'.
However, if someone checks all the checkboxes the answer has to put commas between the values and the word "and" before the last value, so the bookmark then becomes...
'blue, red, green and yellow'
Basically, in simply language, I need to program...
If single checkbox selected then bookmark = checkboxX.value
If 2 checkboxes selected then bookmark = checkboxX.value + " and " + checkboxY.value
If 3 checkboxes selected then bookmark = checkboxX.value + ", " + checkboxY.value + " and " + checkboxZ.value
If 4 checkboxes selected then bookmark = checkboxX.value + ", " + checkboxY.value + ", " + checkboxZ.value + " and " + checkboxW.value
hope this makes sense?
I don't know how to do this grammatically. Can anyone point me in the right direction or reference a technique?
Thanks very much.
I have a simple userform with 4 checkboxes. In my example the values of these are set to colors:
checkbox1.value = "blue"
checkbox2.value = "red"
checkbox3.value = "green"
checkbox4.value = "yellow"
The user has to select at least one checkbox, but can select more than one, up to all 4 checkboxes.
If the user checks a single box, such as checkbox1, then then my code updates a bookmark to the value, in this case 'blue'.
However, if someone checks all the checkboxes the answer has to put commas between the values and the word "and" before the last value, so the bookmark then becomes...
'blue, red, green and yellow'
Basically, in simply language, I need to program...
If single checkbox selected then bookmark = checkboxX.value
If 2 checkboxes selected then bookmark = checkboxX.value + " and " + checkboxY.value
If 3 checkboxes selected then bookmark = checkboxX.value + ", " + checkboxY.value + " and " + checkboxZ.value
If 4 checkboxes selected then bookmark = checkboxX.value + ", " + checkboxY.value + ", " + checkboxZ.value + " and " + checkboxW.value
hope this makes sense?
I don't know how to do this grammatically. Can anyone point me in the right direction or reference a technique?
Thanks very much.