Skip to content

Instantly share code, notes, and snippets.

@tombrad
Created February 13, 2013 04:18
Show Gist options
  • Save tombrad/4942225 to your computer and use it in GitHub Desktop.
Save tombrad/4942225 to your computer and use it in GitHub Desktop.
Prototipos VBA-3-7
Private Sub CommandButton1_Click()
Rem posicion del indice en la celda 1,1
indice = Hoja2.Cells(1, 1)
Rem si el indice es cero se cambia a uno
If indice = "" Then
indice = 1
Hoja2.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
Hoja2.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
Hoja2.Cells(indice, 1) = ComboBox2.ListIndex + 1
Hoja2.Cells(indice, 2) = TextBox1.Text
Hoja2.Cells(indice, 3) = TextBox2.Text
Hoja2.Cells(indice, 4) = TextBox3.Text
Hoja2.Cells(indice, 5) = ComboBox1.Text
Rem limpia todos los textbox
TextBox2.Text = ""
TextBox3.Text = ""
Rem coloca el foco en textbox1
ComboBox2.SetFocus
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment