Captura De Datos Para Macros En Excel

Páginas: 3 (641 palabras) Publicado: 23 de abril de 2012
CAPTURA DE DATOS

Private Sub CommandButton1_Click()
Rem Ubicamos elcursor e insertamos una fila
If TextBox1.Text "" Then
Range("A9").Select
Selection.EntireRow.Insert
Rem Ubicamos el cursoren la celda A9
Range("A9").Select
Rem Insertamos el texto en A9
ActiveCell.FormulaR1C1 = TextBox1
Rem Repetimos con Textbox2 y TextBox3
Range("B9").Select
ActiveCell.FormulaR1C1 =Val(TextBox2)
Range("C9").Select
ActiveCell.FormulaR1C1 = Val(TextBox3)
Rem ubicamos el cursor en la celda D9
Range("D9").Select
ActiveCell.FormulaR1C1 = Val(TextBox2) * Val(TextBox3)
Rem Empty LimpiamosLos TextBox
TextBox1 = Empty
TextBox2 = Empty
TextBox3 = Empty
Rem TextBox1.SetFocus ponemos el cursor en TextBox1
Else
MsgBox "Escriba un producto"
End If
TextBox1.SetFocus
End SubPrivate Sub CommandButton2_Click()
Rem Oculta el formulario
UserForm1.Hide
End Sub






EJEMPLO DE SECUENIAL SIMPLE

Sub SelectivaSimple()
' Poner las casillas donde se guardan los valores 0.ActiveSheet.Range("A1").Value = 0
ActiveSheet.Range("A2").Value = 0
ActiveSheet.Range("A3").Value = 0
ActiveSheet.Range("A1").Value = Val(InputBox("Entrar el precio", "Entrar"))
' Si el valorde la casilla A1 es mayor que 1000, entonces, pedir descuento
If ActiveSheet.Range("A1").Value > 1000 Then
ActiveSheet.Range("A2").Value = Val(InputBox("Entrar Descuento", "Entrar"))
End IfActiveSheet.Range("A3").Value = ActiveSheet.Range("A1").Value - _
ActiveSheet.Range("A2").Value
End Sub


Sub Condicional()
Dim Precio As Integer
Dim Descuento As Integer
Precio = 0
Descuento = 0Precio = Val(InputBox("Entrar el precio", "Entrar"))
' Si el valor de la variable precio es mayor que 1000, entonces, pedir descuento
If Precio > 1000 Then
Descuento = Val(InputBox("EntrarDescuento", "Entrar"))
End If
ActiveSheet.Range("A1").Value = Precio
ActiveSheet.Range("A2").Value = Descuento
ActiveSheet.Range("A3").Value = Precio - Descuento
End Sub

Sub Condicional2()
If...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • Aprende Macros para Excel
  • Para que sirve excel y que es una base de datos
  • Creación de una macro sencilla en Excel para tareas rutinarias
  • Captura De Datos
  • capturista de datos
  • Capturista De Datos
  • Macros En Excel
  • Macros de excel

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS