Actividad 1
Operaciones Aritméticas ejemplo "Hola"
Sub op_aritmetico()
Cells(1, 1) = "hola"
Range("B2") = "Tu"
Range("A2:A5") = " Hola UwU"
End Sub
Actividad 2Aritméticas "Suma, resta,multiplicación, división y producto"
Sub aritmeticas()
Dim num1 As Integer
Dim num2 As Integer
num1 = 5
num2 = 7
Cells(1, 1) = num1 + num2 'suma
Cells(1, 2) = "suma"
Cells(2, 1) = num2 - num1 'resta
Cells(2, 2) = "resta"
Cells(3, 1) = num1 * num2 'multiplicacion
Cells(3, 2) = "multiplicacion"
Cells(4, 1) = num2 / num1 'division
Cells(4, 2) = "Division"
Cells(5, 1) = num1 ^ 2 'potencia
Cells(5, 2) = "potencia"
Cells(6, 1) = num2 \ num1 'division entera
Cells(6, 2) = "Division entera"
Cells(7, 1) = num2 Mod num1 'residuo
Cells(7, 2) = "Residuo"
End Sub
Actividad 3función lógicos
Sub logicos()
Dim n1 As Integer
Dim n2 As Integer
n1 = 5 'asignacion
n2 = 0
Cells(1, 1) = "n1=5"
Cells(1, 2) = n1
'If n = 5 Then
'Cells(2, 1) = "comparacion"
'Cells(2, 2) = n1
'End If
Cells(2, 1) = "And"
Cells(2, 1) = n1 And n2
Cells(3, 1) = "Or"
Cells(3, 2) = n1 Or n2
Cells(4, 1) = "Xor"
Cells(4, 2) = n1 Xor n2
Cells(5, 1) = "Not"
Cells(5, 2) = Not n1
End Sub
Función "Relacionales"
Sub op_relacionales()
Dim n1 As Integer
Dim n2 As Integer
n1 = 4
n2 = 8
Cells(1, 1) = "menor que"
Cells(2, 1) = n1 < n2
Cells(3, 1) = n1 <= n2
Cells(1, 2) = "mayor que"
Cells(2, 2) = n1 > n2
Cells(3, 2) = n1 >= n2
Cells(1, 3) = "igual a"
Cells(2, 3) = n1 = n2
Cells(1, 4) = "no igual"
Cells(2, 4) = n1 <> n2
End Sub
Creación de palabras con función "Cadenas"
Sub cadenas()
Dim x As String
Dim y As String
x = "pro" & "gra" & "macion"
y = "pro" + "gra" + "macion"
Range("a1") = x
Range("b1") = y
End Sub
Tabla de multiplicación
Sub tabla()
Range("A1") = "Tabla de multiplicacion del 8"
Range("A2") = "8*1="
Range("B2") = 8 * 1
Range("A3") = "8*2="
Range("B3") = 8 * 2
Range("A4") = "8*3="
Range("B4") = 8 * 3
Range("A5") = "8*4="
Range("B5") = 8 * 4
Range("A6") = "8*5="
Range("B6") = 8 * 5
Range("A7") = "8*6="
Range("B7") = 8 * 6
Range("A8") = "8*7="
Range("B8") = 8 * 7
Range("A9") = "8*8="
Range("B9") = 8 * 8
Range("A10") = "8*9="
Range("B10") = 8 * 9
End Sub
Grabando Macro para crear una tabla
Instrucción: enumera del 1 al 12 engrosar columna y contorno azul"
Actividad 8
crear acceso directo a macro personalizado
Macro "agregar libro y colorear celda"
Actividad 10
Macro "Agregar tabla de multiplicación del 8"
Sub tabladel8()
'
' tabladel8 Macro
' imprimir de colores la tabla del 8
'
'
Range("A1:B1").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Merge
Range("A2:A7").Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent1
.TintAndShade = 0.599993896298105
.PatternTintAndShade = 0
End With
Range("B2:B7").Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent2
.TintAndShade = 0.599993896298105
.PatternTintAndShade = 0
End With
Range("A1") = "Tabla de multiplicacion del 8"
Range("A2") = "8*1="
Range("B2") = 8 * 1
Range("A3") = "8*2="
Range("B3") = 8 * 2
Range("A4") = "8*3="
Range("B4") = 8 * 3
Range("A5") = "8*4="
Range("B5") = 8 * 4
Range("A6") = "8*5="
Range("B6") = 8 * 5
Range("A7") = "8*6="
Range("B7") = 8 * 6
Range("A8") = "8*7="
Range("B8") = 8 * 7
Range("A9") = "8*8="
Range("B9") = 8 * 8
Range("A10") = "8*9="
Range("B10") = 8 * 9
End Sub
Actividad 11
Función "Saludar"
Sub saluda()
Range("A5").Select
ActiveCell.FormulaR1C1 = "Hola Celda"
Range("B5").Select
ActiveCell.FormulaR1C1 = "Programacion"
End Sub
Actividad 12
Función "saluda 2"
Sub saluda2()
Dim cad As String
Dim num As Integer
cad = "Hola"
Range("C5") = "2023"
Range("D2") = "Whats up"
num = Cells(5, 3).Value
Var = Cells(2, 4).Value
MsgBox (Var)
'Msgbox (num)
MsgBox (cad)
End Sub
Formato de celda
Sub formato()
Cells(1, 5).Value = "Hola estudiante"
Cells(1, 5).Font.Bold = True
Cells(1, 5).Font.Size = 14
Cells(1, 5).VerticalAlignment = xlCenter
Cells(1, 5).HorizontalAlignment = xlCenter
Cells(1, 5).Borders(xlEdgeBottom).LineStyle = xlContinuous
Cells(1, 5).Borders(xlEdgeBottom).Weight = xlThick
Cells(1, 5).Borders(xlEdgeBottom).Color = RGB(52, 152, 219)
End Sub
Actividad 14
Creación de tablas dinámicas para calcular valores importantes
Actividad 15
Gráficos con base a las tabla dinámicas
Calculando Promedio con tablas dinámicas
Agregar hojas con nombre especifico o personalizado
Sub agregar_hoja()
'Sheets.Add
'sheets.Add before:=sheets(1)
Sheets.Add after:=Sheets(1)
ActiveSheet.Name = "HOLA UwU"
End Sub
Actividad 18
Cambiar nombre a hoja reciente
Sub agregar_hoja()
'Sheets.Add
'sheets.Add before:=sheets(1)
'Sheets.Add after:=Sheets(1)
'ActiveSheet.Name = "HOLA UwU"
Sheets("Hola UwU").Activate
ActiveSheet.Name = "Hola Bro"
End Sub
Actividad 19
Cambia color de pestaña y eliminar cuadricula
Sub cuadricula()
'activewindow.DisplayGridlines=false
ActiveWindow.DisplayGridlines = False
Sheets("Hola Bro").Tab.Color = RGB(255, 128, 128)
End Sub
Cambiar color a celda
Sub cambia_color()
'Range("a1").Interior.Color = RGB(255, 128, 128)
Range("a1").Interior.Color = RGB(255, 128, 128)
End Sub
Actividad 21
Mensaje de bienvenida
Private Sub workbook_open()
MsgBox "Buenos dias SU NOMBRE"
End Sub
Actividad 22
Ajustar zoom al guardar libro
Private Sub workbook_BeforeSave(ByVal saveAsUI As Boolean, cancel As Boolean)
Dim sht As Worksheets
For Each sht In Worksheets
ActiveWindow.Zoom = 100
Next
End Sub
Comentarios
Publicar un comentario