Vous êtes sur la page 1sur 4

Sub Circunferencia() A = Range("B1") B = Range("B2") C = Range("B3") D = Range("B4") E = Range("B5") Range("B7") = Sqr((B - D) ^ 2 + (C - E) ^ 2) Range("B8") = Sqr(B ^ 2 + C ^ 2) Range("B9") = Sqr(D ^ 2 + E ^ 2) If Range("B8") <

Range("B9") Then Range("B10") = "VERDADERO" Else: Range("B10") = "FALSO" End If If Range("B7") > 2 * A Then Range("B11") = "EXTERIORES" Else If Range("B7") = 0 Then Range("B11") = "COINCIDENTES" Else If Range("B7") < 2 * A Then Range("B11") = "SECANTES" Else: Range("B11") = "TANGENTES" End If End If End If End Sub

Sub CALIFICACION() A = Range("A2") B = Range("A3") If Range("A4") <> A + B Then Range("A5") = "INCORRECTO" Else Range("A5") = "CORRECTO" End If A = Range("D2") B = Range("D3") If Range("D4") <> A + B Then Range("D5") = "INCORRECTO" Else Range("D5") = "CORRECTO" End If A = Range("F2") B = Range("F3") If Range("F4") <> A + B Then Range("F5") = "INCORRECTO" Else Range("F5") = "CORRECTO" End If A = Range("H2") B = Range("H3") If Range("H4") <> A + B Then Range("H5") = "INCORRECTO" Else Range("H5") = "CORRECTO" End If A = Range("J2") B = Range("J3") If Range("J4") <> A + B Then Range("J5") = "INCORRECTO" Else Range("J5") = "CORRECTO" End If End Sub

VBA Lesson 20: VBA for Excel Statements Among the VBA statements that you will discover in the downloadable tutorial on Excel macros, there are the "If" statement including Then, ElseIf and End If, there is the "Do" statement including Loop, Until, While and Exit, there is the "For" statement including To, Step, Next and Exit, there is the powerful "Select Case" statement including Case,End Select and Exit and other statements. A lot of visitors ask us how they can delete the entire lines when a certain cell is empty. For example, in the table below rows 2 and 5 should be deleted:

First enter xxx where you want the loop to stop (below the last value: B7). Select the cell at the top of the column containing the values to be considered (B1)and run the macro. Sub proDelete() Range("B1").Select Do Until Selection.Value = "xxx" If Selection.Value = "" Then Selection.EntireRow.Delete Else Selection.Offset(1, 0).Select End If Loop Range("A1").Select End Sub If you have completed the free exercises "Free Basics", just copy/paste the macro above in the Visual Basic editor and run it. Exiting a Loop In the loop above if you want the loop to stop when it finds the value 99 you can add this line of code within the loop: If Selection.Value = 99 Then Exit Do Exit allows you to get out of almost anything like: Exit Sub

Exit For Exit Do


mira si pones "P = Val(InputBox("ingrese un lado del triangulo: ")), quiere decir que te saldr una ventanita en el cual tendrs que ingresar el dato que ests pidiendo, lo cual ese dato lo tomar la variable P es decir, en vez de hacerlo en Excel todo lo puedes hacer en VBA en vez de poner los datos en las celdas, simplemente utilizas esos y ah digitas los datos que requieres intenta ponerle eso para que as te des una idea de cmo funciona

Vous aimerez peut-être aussi