Hello all
Thanks to a previous thread I have been able to set up the following form to have its checkbox captions defined as visible elements of a filtered list.
However due to what I need it to do it spreads the visible checkboxes unevenly across the form obviously because it only shows a checkbox if a visible element of the list is present.
What it should do is take the visible elements, skipping the hidden and not incrementing the variable, and populate them starting with the first checkbox and working through until no more values are left. When that is the case then the checkboxes are made hidden.
I hope this makes sense and if anyone can help I have tried
* setting another variable that goes down one if no value is present and using that as index for checkboxes. This got a bit crazy for me and out of range errors occured.
*defining an array of the values. This worked but did not populate from the first still as somewhere in the array was a blank value that it still stored and used. The main reason this was a problem was the above.
It all kept coming down to the same problem irrespective of the solution I tried I couldnt either:
*keep the variable associated with checkbox static if the element was hidden
*send the variable down if the element was hidden
Sorry for the length of explanation, but I know what I want in words just cant code it.
Anyway here are two of my efforts, done using a form with 10 checkboxes, but a solution populating cells would be fine as I could recode that.
This version works but only gets the first value as the first checkbox caption and then goes wrong
Sub UserForm_Initialize()
Let r = 3 ' this is correct
For i = 3 To 10
cb = (r - 3) + 1
If Worksheets("Sheet1").Rows(r).Hidden = False Then Me.Controls("CheckBox" & cb).Caption = Cells(r, 1) Else Me.Controls("CheckBox" & cb).Visible = False
r = r + 1
Next i
End Sub
This version works as well but does not put the first value in the first checkbox caption
Sub UserForm_Initialize()
Let r = 3 ' this is correct
For i = 3 To 10
If Worksheets("Sheet1").Rows(r).Hidden = False Then Me.Controls("CheckBox" & i).Caption = Cells(r, 1) Else Me.Controls("CheckBox" & i).Visible = False
r = r + 1
Next i
End Sub
Cheers
Neil
Thanks to a previous thread I have been able to set up the following form to have its checkbox captions defined as visible elements of a filtered list.
However due to what I need it to do it spreads the visible checkboxes unevenly across the form obviously because it only shows a checkbox if a visible element of the list is present.
What it should do is take the visible elements, skipping the hidden and not incrementing the variable, and populate them starting with the first checkbox and working through until no more values are left. When that is the case then the checkboxes are made hidden.
I hope this makes sense and if anyone can help I have tried
* setting another variable that goes down one if no value is present and using that as index for checkboxes. This got a bit crazy for me and out of range errors occured.
*defining an array of the values. This worked but did not populate from the first still as somewhere in the array was a blank value that it still stored and used. The main reason this was a problem was the above.
It all kept coming down to the same problem irrespective of the solution I tried I couldnt either:
*keep the variable associated with checkbox static if the element was hidden
*send the variable down if the element was hidden
Sorry for the length of explanation, but I know what I want in words just cant code it.
Anyway here are two of my efforts, done using a form with 10 checkboxes, but a solution populating cells would be fine as I could recode that.
This version works but only gets the first value as the first checkbox caption and then goes wrong
Sub UserForm_Initialize()
Let r = 3 ' this is correct
For i = 3 To 10
cb = (r - 3) + 1
If Worksheets("Sheet1").Rows(r).Hidden = False Then Me.Controls("CheckBox" & cb).Caption = Cells(r, 1) Else Me.Controls("CheckBox" & cb).Visible = False
r = r + 1
Next i
End Sub
This version works as well but does not put the first value in the first checkbox caption
Sub UserForm_Initialize()
Let r = 3 ' this is correct
For i = 3 To 10
If Worksheets("Sheet1").Rows(r).Hidden = False Then Me.Controls("CheckBox" & i).Caption = Cells(r, 1) Else Me.Controls("CheckBox" & i).Visible = False
r = r + 1
Next i
End Sub
Cheers
Neil