
ocultar checkbok
Publicado por miguel (1 intervención) el 01/07/2023 05:20:40
saludos
tengo un problema con el siguiente codigo ya que que al hacer click en el checkbox del formulario deberia ocultar el label1 y el textbox1 pero no lo hace. me gustaria que me explicaran el porque de esto y me ayudaran a resolverlo. muchisimas gracias a todos.
tengo un problema con el siguiente codigo ya que que al hacer click en el checkbox del formulario deberia ocultar el label1 y el textbox1 pero no lo hace. me gustaria que me explicaran el porque de esto y me ayudaran a resolverlo. muchisimas gracias a todos.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
Private Sub UserForm_Initialize()
Dim lastRow As Long
Dim i As Long
Dim fecha As String
lastRow = Worksheets("Hoja1").Cells(Rows.Count, 6).End(xlUp).Row
For i = 1 To lastRow
fecha = Worksheets("Hoja1").Cells(i, 6).Value
If fecha <> "" And Not IsInList(fecha, ListBox1) Then
ListBox1.AddItem fecha
End If
Next i
End Sub
Private Sub ListBox1_Click()
Dim lastRow As Long
Dim i As Long
Dim fecha As String
Dim representante As String
ListBox2.Clear
fecha = ListBox1.Value
lastRow = Worksheets("Hoja1").Cells(Rows.Count, 6).End(xlUp).Row
For i = 1 To lastRow
If Worksheets("Hoja1").Cells(i, 6).Value = fecha Then
representante = Worksheets("Hoja1").Cells(i, 2).Value
ListBox2.AddItem representante
End If
Next i
End Sub
Private Sub CommandButton1_Click()
Dim lastRow As Long
Dim i As Long
Dim fecha As String
Dim representante As String
fecha = ListBox1.Value
representante = ListBox2.Value
lastRow = Worksheets("Hoja1").Cells(Rows.Count, 6).End(xlUp).Row
For i = 1 To lastRow
If Worksheets("Hoja1").Cells(i, 6).Value = fecha And Worksheets("Hoja1").Cells(i, 2).Value = representante Then
If CheckBox1.Value = True Then
Worksheets("Hoja1").Cells(i, 9).Value = "No Asistió"
Label1.Visible = True
TextBox1.Visible = True
Worksheets("Hoja1").Cells(i, 10).Value = TextBox1.Value
Else
Worksheets("Hoja1").Cells(i, 9).Value = "Asistió"
Label1.Visible = False
TextBox1.Visible = False
End If
Exit For
End If
Next i
' Corrección para ocultar Label1 y TextBox1 cuando CheckBox1 no está marcada
If CheckBox1.Value = False Then
Label1.Visible = True
TextBox1.Visible = True
End If
End Sub
Private Function IsInList(str As String, lb As MSForms.ListBox) As Boolean
Dim i As Long
For i = 0 To lb.ListCount - 1
If lb.List(i) = str Then
IsInList = True
Exit Function
End If
Next i
IsInList = False
End Function
Valora esta pregunta


0