Quiero agregar al código que tengo la sentencia para ordenar
Hola Experto:
Gracias por tus minutos valiosos en ayudar a otros,
soy de esas chicas que les gusta aprender y por mas que he buscado e intentado
aun no doy..
tengo el siguiente código que lo modifique a mi necesidad
y me funciona de maravilla; hasta q me di cuenta que necesitaba ordenar
la información que ingresaba en base a dos columnas
tengo la siguiente base de datos:
Col A: numero de orden de filas con formulas (aun no aprendo como agregar en la misma
macros que le vaya dando numeración de fila)
col B: " cedula" Col C: "localidad" col D:"apellido" Col E: "nombres"
Col F: "departamento" col G: "turno" Col H: "celular" Col G:"cargo"
lo que requiero que una vez ingresado la información automáticamente se me ordene por
la columna "C" donde esta la "localidad" y la columna "D" del apellido del trabajador.-
e intentado fracasando una y otra vez con varias sentencias que he recogido de otros archivos pero no me funciona..
el ultimo es el siguiente:
Range("A2:m5540").Select
Selection.Sort
Key1:=Range("c2:c"), Order1:=xlAscending, Key2:=Range("d2:d" _
), Order2:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal, DataOption2:=xlSortNormal
mi código sin esa sentencia de ordenar es la siguiente : ( la original que no me da problema pero no me ordena)
Private Sub CommandButton1_Click()
Sheets("BASE DE DATOS").Activate
If TextBox2 = "" Or TextBox3 = "" Or TextBox5 = "" _
Or TextBox15 = "" Or TextBox16 = "" Then
MsgBox "Está dejando campos requeridos vacíos favor complete", vbExclamation, "Almacen"
TextBox3.SetFocus
Else
Range("b" & Cells.Rows.Count).End(xlUp).Offset(1).Select
ActiveCell = TextBox2.Value
ActiveCell.Offset(0, 1) = TextBox3.Value
ActiveCell.Offset(0, 2) = TextBox5.Value
ActiveCell.Offset(0, 3) = TextBox15.Value
ActiveCell.Offset(0, 5) = TextBox7.Value
ActiveCell.Offset(0, 6) = TextBox13.Value
ActiveCell.Offset(0, 7) = TextBox14.Value
ActiveCell.Offset(0, 8) = TextBox16.Value
MsgBox "Personal ingresado exitosamente", vbInformation, "Servitap"
TextBox2 = ""
TextBox3 = ""
TextBox5 = ""
TextBox15 = ""
TextBox7 = ""
TextBox13 = ""
TextBox14 = ""
TextBox16 = ""
TextBox2.SetFocus
End If
End Sub
Private Sub CommandButton4_Click()
Unload Me
End Sub
Private Sub CommandButton5_Click()
Unload Me
Buscarpersonal1.Show
End Sub
Private Sub CommandButton6_Click()
Unload Me
eliminapersonal.Show
End Sub
Private Sub TextBox2_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If Len(TextBox2) = 9 Then
TextBox2 = 0 & TextBox2
CommandButton2.Enabled = True
Exit Sub
Else
End If
End Sub
Private Sub TextBox3_Change()
End Sub
Private Sub TextBox5_Change()
End Sub
Private Sub TextBox7_Change()
End Sub
Private Sub TextBox15_Change()
End Sub
Private Sub TextBox14_Change()
End Sub
Private Sub TextBox2_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If KeyAscii < 45 And KeyAscii <= 75 Then KeyAscii = 0
End Sub