Skip to content

Instantly share code, notes, and snippets.

@tombrad
Created February 13, 2013 04:19
Show Gist options
  • Save tombrad/4942232 to your computer and use it in GitHub Desktop.
Save tombrad/4942232 to your computer and use it in GitHub Desktop.
Prototipos VBA-3-9
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
Rem coloca el nuevo valor del indice -incrementado- en la celda 1,1
Hoja1.Cells(1, 1) = indice
Rem escribe los contenidos de los textbox en la hoja 1
Rem la fila es el valor del indice y la columna varia segun el contenido
Hoja1.Cells(indice, 1) = TextBox1.Text
Hoja1.Cells(indice, 2) = TextBox2.Text
Hoja1.Cells(indice, 3) = TextBox3.Text
Hoja1.Cells(indice, 4) = TextBox4.Text
Rem limpia todos los textbox
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
Rem coloca el foco en textbox1
TextBox1.SetFocus
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment