I’ve got a table of 9 rows of 4 logical elements each. Each row can only have 1 “true” condition in it (An analogy could be: Row1-eyes “Blue”, “Green”, “Grey”, Brown”. Row2-hair “Blond(e)”, “Brunette”, “Redhead”, “None”…and so on.). These are actually “radio buttons” on a user form. They function correctly at the moment, but 100% manually – and I need to keep that facility.
My problem is that I also want to be able to reset them all with “standard” configurations that are determined elsewhere. The buttons are labelled B11 – B49
In the “elsewhere” I have the following sample code that creates the values that I want to set the buttons to:
`Sub bMostCommon() 'This is the most common profile
For iRow = LBound(xLiabilities, 1) To UBound(xLiabilities, 1)
For iCol = LBound(xLiabilities, 2) To UBound(xLiabilities, 2)
xLiabilities(iRow, iCol) = False
Next iCol
Next iRow
'store commomn settings
xLiabilities(1, 1) = True
xLiabilities(2, 2) = True
xLiabilities(2, 3) = True
xLiabilities(1, 4) = True
xLiabilities(1, 5) = True
xLiabilities(1, 6) = True
xLiabilities(1, 7) = True
xLiabilities(1, 8) = True
xLiabilities(2, 9) = True
end sub
The initial variables are dimensioned thus:
Dim xLiabilities(1 To 4, 1 To 9)
Dim iRow As Integer, iCol As Integer
This creates a 2-dimentional array that I want to map onto the corresponding radio buttons.
Within the Userform that contains the radio button array, I have the following code to create the button names:
For iRow = LBound(xLiabilities, 1) To UBound(xLiabilities, 1)
For iCol = LBound(xLiabilities, 2) To UBound(xLiabilities, 2)
mRadioButton = "B" & iRow & iCol
Debug.Print "xLiabilities(" & iRow & "," & iCol & ")" '&
Debug.Print "Radio Button"; mRadioButton
Next iCol
Next iRow
This creates, I believe from studying the debug.print results, the correct output, but I can see no way to extract that output data and use it (e.g B23.Value = Array(2,3).Value and so on, for all 36 radio buttons/elements.
Can this be done or is there a simpler method I’ve missed?
On a userform you can access a specific control using: