Documentos de Académico
Documentos de Profesional
Documentos de Cultura
CALCULADORA
Elaborar una macro para calcular las operaciones básicas suma, resta multiplicación y división
Poner 1 etiqueta= calculadora
Poner 3 cuadros de texto = primer valor, segundo valor, resultado
Poner 2 tiquetas de = + y =
Poner un comando de suma, resta, mulplicacion y división
Else
MsgBox ("Valores invalidos")
'Limpiar las cajas de texto
TextBox1 = Empty
TextBox2 = ""
TextBox3 = ""
End If
End Sub
Range("A2") = "Resta"
Range("B2") = TextBox1.Value Para ubicar en una celda
Range("C2") = TextBox2.Value
Range("D2") = TextBox3.Value
Range("A2").Select
Selection.EntireRow.Insert
Else
MsgBox ("Valores invalidos")
'Limpiar las cajas de texto
TextBox1 = ""
TextBox2 = ""
TextBox3 = ""
End If
Label1 = "-"
End Sub
----------------------------------------------------------
Private Sub CommandButton3_Click()
'Macro para realizar multiplicacion
'Condicion para validar las cajas vacias
If (TextBox1.Value = "" Or TextBox2.Value = "") Then
MsgBox ("Ingreso invalido")
ElseIf (IsNumeric(TextBox1.Value) And IsNumeric(TextBox2.Value)) Then
TextBox3 = Round(Val(TextBox1.Value) * Val(TextBox2.Value), 2)
Range("A2") = "Multiplicacion"
Range("B2") = TextBox1.Value
Range("C2") = TextBox2.Value
Range("D2") = TextBox3.Value
Range("A2").Select
Selection.EntireRow.Insert
Else
MsgBox ("Valores invalidos")
'Limpiar las cajas de texto
TextBox1 = ""
TextBox2 = ""
TextBox3 = ""
End If
Label1 = "*"
End Sub
------------------------------------------------------------------------------
Private Sub CommandButton4_Click()
'Macro para realizar division
'Condicion para validar las cajas vacias
If (TextBox1.Value = "" Or TextBox2.Value = "") Then
MsgBox ("Ingreso invalido")
ElseIf (IsNumeric(TextBox1.Value) And IsNumeric(TextBox2.Value)) Then
TextBox3 = Round(Val(TextBox1.Value) / Val(TextBox2.Value), 2)
Range("A2") = "Division"
Range("B2") = TextBox1.Value
Range("C2") = TextBox2.Value
Range("D2") = Round(TextBox3.Value, 2)
Range("A2").Select
Selection.EntireRow.Insert
Else
MsgBox ("Valores invalidos")
'Limpiar las cajas de texto
TextBox1 = ""
TextBox2 = ""
TextBox3 = ""
End If
Label1 = "/"
End Sub
BRÚJULA
Elaborar una macro que solicite los grados (0 - 360)
mediante un formulario y de acuerdo al valor ingresado muestre los puntos cardinales Norte, Este, Oeste y Sur.
• El programa debe indicar el punto cardinal:
• a) Norte, al ingresar un valor entre 316 y 45 grados.
• b) Este, al ingresar un valor entre 46 y 135 grados.
• c) Sur, al ingresar un valor entre 136 y 225 grados.
° c) Oeste, al ingresar un valor entre 226 y 315 grados.
d) De lo contrario indicar "valor incorrecto
Formulario: ingrese un valor, punto cardinal , ab calcular
---------------------------------------------------------------------------
Private Sub CommandButton1_Click()
End If
End If
End Sub
End Sub
--------------------------------------------------------------------------------
Sub MacroDouble()
'1763556 - Isabela Salazar
'Macro para el manejo de la variable Double
Dim VarDouble1 As Double
Dim VarDouble2 As Double
End Sub
----------------------------------------------------------------------------------------
Sub MacroFecha()
'1763556 - Isabela Salazar
'Macro para el manejo de la variable Date
Dim VarDate As Date
VarDate = Now
Range("F12") = VarDate
Range("F13") = Time()
Range("F14") = Format(Weekday(VarDate), "dddd")
Range("F15") = Day(VarDate)
Range("F16") = Month(VarDate)
Range("F17") = Year(VarDate)
Range("F18") = Hour(VarDate)
Range("F19") = Minute(VarDate)
Range("F20") = Second(VarDate)
End Sub
--------------------------------------------------------------------------------------
Sub MacroNotas()
'1763556 - Isabela Salazar
'Macro para la variable Double
Dim VarDoble1 As Double
Dim VarDoble2 As Double
Dim VarDoble3 As Double
Range("B1") = VarDoble1
Range("B2") = VarDoble2
Range("B3") = VarDoble3
Range("B4") = Round(WorksheetFunction.Average(VarDoble1, VarDoble2, VarDoble3), 2)
'Calificacion de notas
If (Range("B4") > 0 And Range("B4") <= 2.9) Then
Range("B5") = "Insuficiente"
Else
Range("B5") = "Sobresaliente"
End If
End Sub
---------------------------------------------------------------------------
IMC
Range("D4").Select
ActiveCell.FormulaR1C1 = "=(R[-2]C)/R[-1]C^2"
Range("D4").Select
'Construir la funcion Si
If (Range("D4") < 18.5) Then
Range("D5") = "Infrapeso"
ElseIf (Range("D4") >= 18.5 And Range("D4") < 25) Then Range("D5") = "Normal"
ElseIf (Range("D4") >= 25 And Range("D4") < 30) Then Range("D5") = "Sobrepeso"
Else
Range("D5") = "Obeso"
End If
End sud
UserForm1
Private Sub CommandButton1_Click()
'CALCULAR IMC
TextBox3.Value = TextBox2.Value / (TextBox1.Value * TextBox1.Value)
'Encontrar la clasificacion
If (TextBox3.Value < 18.5) Then
TextBox4.Value = "Infrapeso"
Else
TextBox4.Value = "Obeso"
End If