PRACTICA DE MACROS

Page 1

CETPRO SAN MARTIN

PRÁCTICA CALIFICADA

Programación en Hoja de Cálculo

Alumno:……………………………………………………………… Fecha:……………… 1) Cree una lista de alumnos con sus notas:

Userform1.show Userform2.show Userform3.show Userform4.show

2) UserForm1:

Private Sub UserForm_ACTIVATE() Range("A2").Select ListBox1.Clear Do Until ActiveCell.Value = Empty ListBox1.AddItem (ActiveCell.Value) ActiveCell.Offset(1, 0).Select Loop End Sub Private Sub TextBox1_Change() Range("A2").Select ListBox1.Clear Do Until ActiveCell.Value = Empty If InStr(UCase(ActiveCell.Value), UCase(TextBox1)) > 0 Then ListBox1.AddItem (ActiveCell.Value) End If ActiveCell.Offset(1, 0).Select Loop End Sub

3) UserForm2:

Private Sub CommandButton1_Click() If ListBox1.ListIndex >= 0 Then Range("A2").Select Do Until ActiveCell.Value = ListBox1 ActiveCell.Offset(1, 0).Select Loop Me.Hide Else MsgBox ("DEBE ELEGIR UN ALUMNO DE LA LISTA") End If End Private Sub CommandButton1_Click() If TextBox1 <> Empty And TextBox2 <> Empty And TextBox3 <> Empty Then Range("A2").Select Do Until ActiveCell.Value = Empty ActiveCell.Offset(1, 0).Select Loop ActiveCell.Value = TextBox1 + " " + TextBox2 + ", " + TextBox3 Else MsgBox "DATOS INCOMPLETOS" End If End Sub

Jr. Tacna 261 – Chosica  3610523

Pág. 1


CETPRO SAN MARTIN

Programación en Hoja de Cálculo

4) UserForm3:

Private Sub UserForm_ACTIVATE() Range("A2").Select ListBox1.Clear Do Until ActiveCell.Value = Empty ListBox1.AddItem (ActiveCell.Value) ActiveCell.Offset(1, 0).Select Loop End Sub

5)

Private Sub TextBox1_Change() Range("A2").Select ListBox1.Clear Do Until ActiveCell.Value = Empty If InStr(UCase(ActiveCell.Value), UCase(TextBox1)) > 0 Then ListBox1.AddItem (ActiveCell.Value) End If ActiveCell.Offset(1, 0).Select Loop End Sub Private Sub ListBox1_Click() If ListBox1.ListIndex >= 0 Then TextBox2 = ListBox1 End If End Sub

6) UserForm4:

Private Sub CommandButton1_Click() If ListBox1.ListIndex >= 0 Then Range("A2").Select Do Until ActiveCell.Value = ListBox1 ActiveCell.Offset(1, 0).Select Loop ActiveCell.Value = TextBox2 Me.Hide Else MsgBox ("DEBE ELEGIR UN ALUMNO DE LA LISTA") End If End Sub

Los códigos del USERFORM.ACTIVATE y TEXTBOX1 como buscador son iguales a los de los formularios anteriores.

Private Sub CommandButton1_Click() If ListBox1.ListIndex >= 0 Then Range("A2").Select Do Until ActiveCell.Value = ListBox1 ActiveCell.Offset(1, 0).Select Loop Selection.EntireRow.Delete Me.Hide Else MsgBox ("DEBE ELEGIR UN ALUMNO DE LA LISTA") End If End Sub

Jr. Tacna 261 – Chosica  3610523

Pág. 2


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.