mercredi 2 janvier 2019

Loop to extract value from checkbox

A form I am working with has 10 checkboxes, with values 1 through 10, used to answer a multiple choice question.

Multiple values are technically possible (clicking on multiple boxes), but they are not allowed (while filling, only one value should be given). I cannot modify this form so I have to work with this setup.

I need to extract the given choice and paste it into a different worksheet. Using this question I can extract the value of every single checkbox and develop a IF Loop.

If ExtractionSheet.Shapes("Check Box 1").OLEFormat.Object.Value = 1 Then

Database.Cells(5, 9).Value = 1

ElseIf ExtractionSheet.Shapes("Check Box 2").OLEFormat.Object.Value = 1 Then

Database.Cells(5, 9).Value = 2

ElseIf ExtractionSheet.Shapes("Check Box 3").OLEFormat.Object.Value = 1 Then

Database.Cells(5, 9).Value = 3

...

However, this does not look very efficient (I have 3 sets of 1-10 checkboxes per form and 100+ forms). Given the setup, I cannot figure out a better way to do it.

How can I improve the extraction without using an IF loop?




Aucun commentaire:

Enregistrer un commentaire