Sub Circunferencia

Embed Size (px)

Citation preview

  • 7/31/2019 Sub Circunferencia

    1/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

  • 7/31/2019 Sub Circunferencia

    2/4

    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

  • 7/31/2019 Sub Circunferencia

    3/4

    VBA Lesson 20: VBA for Excel StatementsAmong the VBA statements that you will discover in the downloadable tutorialon 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 "SelectCase" 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 isempty. 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 beconsidered (B1)and run the macro.Sub proDelete()

    Range("B1").SelectDo Until Selection.Value = "xxx"

    If Selection.Value = "" ThenSelection.EntireRow.Delete

    ElseSelection.Offset(1, 0).Select

    End IfLoopRange("A1").Select

    End SubIf you have completed the free exercises "Free Basics", just copy/paste themacro above in the Visual Basic editor and run it.Exiting a LoopIn the loop above if you want the loop to stop when it finds the value 99 youcan add this line of code within the loop:If Selection.Value = 99 Then Exit DoExit allows you to get out of almost anything like:

    Exit Sub

    http://www.excel-vba.com/Documents%20and%20Settings/Pierre%20Leclair/Desktop/Sites%20Web/07-09-2010/000-Sites%20Web/a-excel-vba/excel-macros-beginners.htmhttp://www.excel-vba.com/Documents%20and%20Settings/Pierre%20Leclair/Desktop/Sites%20Web/07-09-2010/000-Sites%20Web/a-excel-vba/excel-macros-beginners.htmhttp://www.excel-vba.com/Documents%20and%20Settings/Pierre%20Leclair/Desktop/Sites%20Web/07-09-2010/000-Sites%20Web/a-excel-vba/excel-macros-beginners.htmhttp://www.excel-vba.com/Documents%20and%20Settings/Pierre%20Leclair/Desktop/Sites%20Web/07-09-2010/000-Sites%20Web/a-excel-vba/excel-macros-beginners.htm
  • 7/31/2019 Sub Circunferencia

    4/4

    Exit ForExit Domira si pones "P = Val(InputBox("ingrese un lado del triangulo: ")), quiere decir que te saldr unaventanita en el cual tendrs que ingresar el dato que ests pidiendo, lo cual ese dato lo tomar la

    variable Pes 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 querequieres

    intenta ponerle eso para que as te des una idea de cmo funciona