Skip to content

Instantly share code, notes, and snippets.

View tombrad's full-sized avatar

Tomas Bradanovic tombrad

View GitHub Profile
@tombrad
tombrad / gist:4942212
Created February 13, 2013 04:14
Prototipos VBA-3-3
Private Sub CommandButton3_Click()
Rem para agregar un nuevo movimiento
Rem se carga userform2
Load UserForm2
Rem se muestra userforrm2
UserForm2.Show
End Sub
@tombrad
tombrad / gist:4942210
Created February 13, 2013 04:13
Prototipos VBA-3-2
Private Sub CommandButton1_Click()
Rem para agregar nueva cuenta
Rem se carga userform3
Load UserForm3
Rem se muestra userforrm2
UserForm3.Show
End Sub
@tombrad
tombrad / gist:4942204
Created February 13, 2013 04:12
Prototipos VBA-3-1
Private Sub ComboNombre_Click()
Rem al escoger un item del combobox hace lo siguiente
Rem coloca el costo en textbox1
saldo = 0
CodCliente = ComboNombre.ListIndex + 1
TextBox1.Text = Hoja1.Cells(CodCliente, 2)
Rem coloca el precio de venta (lista) en textbox2
TextBox2.Text = Hoja1.Cells(CodCliente, 3)
TextBox3.Text = Hoja1.Cells(CodCliente, 4)
ultimo = Hoja2.Cells(1, 1)
@tombrad
tombrad / gist:4942196
Created February 13, 2013 04:10
Prototipos VBA-2-6
Private Sub CommandButton1_Click()
Rem posicion del indice en la celda 1,1
indice = Hoja1.Cells(1, 1)
Rem si el indice es cero se cambia a uno
If indice = "" Then
indice = 1
Hoja1.Cells(1, 1) = indice
End If
Rem incrementa el indice en 1 lugar que es la fila donde debe grabar
indice = indice + 1
@tombrad
tombrad / gist:4942193
Created February 13, 2013 04:09
Prototipos VBA-2-5
Private Sub UserForm_Activate()
Rem llena los valores del combo cada vez que parte el programa userform_activate
Rem para ello primero parte de la posicion 2
Rem y cambia los valores de z desde 1 a 500
Rem y con el metodo additem llena al combo de valores (nombres de articulos)
If Hoja1.Cells(1, 1) <> "" Then
For z = 1 To 500
ComboNombre.AddItem Hoja1.Cells(z, 1)
Next z
Rem deja en blanco el combo
@tombrad
tombrad / gist:4942190
Created February 13, 2013 04:08
Prototipos VBA-2-.4
Private Sub TextBox3_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Rem calcula el total de la venta y lo coloca en textbox4.text
TextBox4.Text = TextBox2.Text * TextBox3.Text
End Sub
@tombrad
tombrad / gist:4942187
Created February 13, 2013 04:07
Prototipos VBA-2-3
Private Sub CommandButton2_Click()
Rem al ingresar la venta
Rem el saldo esta en hoja1.cells de la linea de combo que elegimos
Rem que en la hoja exel seria la posicion combonombre.listindex + 1
Rem recordar el formato Hoja1.Cells(linea,columna)
Rem luego toma el valor (cantidad) almacenado en esa celda y le resta el valor de textbox3.text
Hoja1.Cells(ComboNombre.ListIndex + 1, 2) = Hoja1.Cells(ComboNombre.ListIndex + 1, 2) - TextBox3.Text
Rem con eso deja la cantidad rebajada
Rem luego limpia los textbox combo y pone el foco en combonombre
TextBox1.Text = ""
@tombrad
tombrad / gist:4942184
Created February 13, 2013 04:06
Prototipos VBA-2-2
Private Sub CommandButton1_Click()
Rem para agregar un nuevo articulo
Rem se carga userform2
Load UserForm2
Rem se muestra userforrm2
UserForm2.Show
End Sub
@tombrad
tombrad / gist:4942181
Created February 13, 2013 04:05
Prototipos VBA-2-1
Private Sub ComboNombre_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Rem al escoger un item del combobox hace lo siguiente
Rem coloca el costo en textbox1
TextBox1.Text = Hoja1.Cells(2, 2)
Rem coloca el precio de venta (lista) en textbox2
TextBox2.Text = Hoja1.Cells(2, 3)
End Sub
@tombrad
tombrad / gist:4942167
Created February 13, 2013 04:03
Prototipos VBA-1
Private Sub CommandButton1_Click()
indice = Hoja1.Cells(1, 1)
If indice = "" Then
indice = 1
Hoja1.Cells(1, 1) = indice
End If
indice = indice + 1
Hoja1.Cells(1, 1) = indice
Hoja1.Cells(indice, 1) = TextBox1.Text
Hoja1.Cells(indice, 2) = TextBox2.Text