I have the following in my OptieRestricties tab in Excel:
I have the following VBA code:
Private Sub CommandButton_Click()
Dim i As Long
Dim p As Long
Dim Item As String
Dim ifcond As String
Dim thencond As String
Excel.Worksheets("OptieRestricties").Select
With ActiveSheet
i = 2
Do Until IsEmpty(.Cells(i, 2))
p = 4
Do Until IsEmpty(.Cells(2, p))
ifcond = ActiveSheet.Cells(i, 2)
thencond = ActiveSheet.Cells(i, 3)
Item = ActiveSheet.Cells(i, p)
If Not IsEmpty(Item) Then
Debug.Print Item & " --- " & ifcond & " " & thencond
End If
p = p + 1
Loop
i = i + 1
Loop
End With
End Sub
The code returns the following result:
Kraker_child_1 --- [775](16).value=0 [775](12,13,14,15,17,18,19).visible=0;[775](12,13,14,15,18,19).udf2=0;
However, how can the code be modified such that it returns the following? (note that I want to be able to add items in columns that come after E as well (e.g in f, g, h etc.)):
Kraker_child_1 --- [775](16).value=1 [775](12,13,14,15,17,18,19).visible=1
Kraker_child_1 --- [775](16).value=0 [775](12,13,14,15,17,18,19).visible=0;[775](12,13,14,15,18,19).udf2=0;
Kraker_child_1 --- [775](16).value=0 [775](12,13,14,15,17,18,19).visible=0;[775](12,13,14,15,18,19).udf2=0;
Update
The output that I am getting after applying the code from Paul with the following excel structure:
Yields the following output:
child_3 ---> [775](16).value=1 >>> [775](12,13,14,15,17,18,19).visible=1
child_2 ---> [775](16).value=0 >>> [775](12,13,14,15,17,18,19).visible=0;[775](12,13,14,15,18,19).udf2=0;
While it should return:
child ---> [775](16).value=1 >>> [775](12,13,14,15,17,18,19).visible=1
child ---> [775](16).value=1 >>> [775](12,13,14,15,17,18,19).visible=1
child_3 ---> [775](16).value=1 >>> [775](12,13,14,15,17,18,19).visible=1
child_2 ---> [775](16).value=0 >>> [775](12,13,14,15,17,18,19).visible=0;[775](12,13,14,15,18,19).udf2=0;
Update 2
When applying the latest code from Paul to more rows, in my case 111 rows:
the code should print 223 rows in the following format:
child ---> [775](16).value=1 >>> [775](12,13,14,15,17,18,19).visible=1
childa ---> [775](16).value=1 >>> [775](12,13,14,15,17,18,19).visible=1
child_b ---> [775](16).value=1 >>> [775](12,13,14,15,17,18,19).visible=1
child ---> [775](16).value=0 >>> [775](12,13,14,15,17,18,19).visible=0;[775](12,13,14,15,18,19).udf2=0;
childa ---> [775](16).value=0 >>> [775](12,13,14,15,17,18,19).visible=0;[775](12,13,14,15,18,19).udf2=0;
.....
However, only 174 rows are printed. So 49 rows are not printed.