Just want to know your idea on this matter. So the thing is I'm trying to show the information in the UserForm with the MultiPage control. I have a Cert sheet where the data are stored. So in the Cert sheet, the count of the data can be equals to 1, 2, or 3. I already figured out the flow for 1 and 3 but I'm having a problem with the 2.
My plan is like this:
- If the
data=2then- If
box=1orbox=2Then- Show data in first and second box
- If
box=1orbox=3Then- Show data in first and third box
- If
box=2orbox=3Then- Show data in second and third box
- If
Here's a visual for your guide.
USERFORM: If the data is equal to 2 or 3, data should be shown in their respective boxes.
SHEET DATA:
The code below is the one that I'm currently using for 2.
For r = 9 To Lastrow
If Application.CountIf(Worksheets(ws_output).Columns(3), LRN) = 2 Then 'data
If _
ws.Cells(r, 3) = CStr( ThisWorkbook.Sheets("HOME").Range("K11").value ) And _
( ws.Cells(r, 12).value = 1 Or ws.Cells(r, 12).value = 2 ) _
Then
If ws.Cells(r, 12).value = 1 Then 'show the data with the value of 1
'FIRST BOX
txtBox_LRN.Text = ws.Cells(r, 3).value
txtBox_name.Text = ws.Cells(r, 4).value
txtBox_grd.Text = ws.Cells(r, 5).value
ElseIf ws.Cells(r, 12).value = 2 Then 'show the data with the value of 2
'SECOND BOX
sb_txtBox_LRN.Text = ws.Cells(r, 3).value
sb_txtBox_name.Text = ws.Cells(r, 4).value
sb_txtBox_grd.Text = ws.Cells(r, 5).value
End If
ElseIf _
ws.Cells(r, 3) = CStr(ThisWorkbook.Sheets("HOME").Range("K11").value) And _
( ws.Cells(r, 12).value = 1 Or ws.Cells(r, 12).value = 3 ) _
Then
If ws.Cells(r, 12).value = 1 Then 'show the data with the value of 1
'FIRST BOX
txtBox_LRN.Text = ws.Cells(r, 3).value
txtBox_name.Text = ws.Cells(r, 4).value
txtBox_grd.Text = ws.Cells(r, 5).value
ElseIf ws.Cells(r, 12).value = 2 Then 'show the data with the value of 3
'THIRD BOX
tb_txtBox_LRN.Text = ws.Cells(r, 3).value
tb_txtBox_name.Text = ws.Cells(r, 4).value
tb_txtBox_grd.Text = ws.Cells(r, 5).value
End If
ElseIf _
ws.Cells(r, 3) = CStr( ThisWorkbook.Sheets("HOME").Range("K11").value ) And _
( ws.Cells(r, 12).value = 2 Or ws.Cells(r, 12).value = 3 ) _
Then
If ws.Cells(r, 12).value = 2 Then 'show the data with the value of 2
'SECOND BOX
sb_txtBox_LRN.Text = ws.Cells(r, 3).value
sb_txtBox_name.Text = ws.Cells(r, 4).value
sb_txtBox_grd.Text = ws.Cells(r, 5).value
ElseIf ws.Cells(r, 12).value = 3 Then 'show the data with the value of 3
'THIRD BOX
tb_txtBox_LRN.Text = ws.Cells(r, 3).value
tb_txtBox_name.Text = ws.Cells(r, 4).value
tb_txtBox_grd.Text = ws.Cells(r, 5).value
End If
End If
End If
Next r
The If box = 1 or box = 2 Then and If box = 1 or box = 3 Then are working but I'm having a problem with If box = 2 or box = 3 Then:
If
data = 2, it runs in the firstIF statementwith the this code:(ws.Cells(r, 12).value = 1 Or ws.Cells(r, 12).value = 2)or if the
data = 3, it runs in this code:(ws.Cells(r, 12).value = 1 Or ws.Cells(r, 12).value = 3)But how can I make it run with this?:
(ws.Cells(r, 12).value = 2 Or ws.Cells(r, 12).value = 3) Then

