Error al Ingresar nuevos clientes
Tengo una planilla de excel, la cual a través de un userform ingreso información sobre clientes, es decir al tener un cliente nuevo, ingreso sus datos en una planilla y le genero un código de cliente. El problema es que solo la planilla me almacena 7 filas, si ingreso 8 clientes me borra uno y así, revisando mi código no he podido encontrar el error y la verdad no se qué hacer.
Private Sub ComboBox1_Change()
Set h = Sheets("CLIENTES")
End Sub
Private Sub registrar_Click()
Dim fila As Long
Dim duplicados As Boolean
'Obtener la fila disponible
fila = Application.WorksheetFunction.CountA(Range("B:B")) + 1
duplicados = False
'Validar si se han ingresado datos duplicados
For i = 1 To fila
If Cells(i, 2).Value = form_clientes.TextBox_nombre.Value Then
If Cells(i, 10).Value = form_clientes.TextBox_rut.Value Then
'Se encontraron datos duplicados
MsgBox "Este Cliente ya ha sido ingresado"
duplicados = True
End If
End If
Next i
If Not duplicados Then
Selection.EntireRow.Insert
'Insertar datos capturados
Cells(fila, 2).Value = form_clientes.TextBox_nombre.Value
Cells(fila, 3).Value = form_clientes.TextBox_empresa.Value
Cells(fila, 5).Value = form_clientes.TextBox_direccion.Value
Cells(fila, 6).Value = form_clientes.TextBox_telefono.Value
Cells(fila, 8).Value = form_clientes.TextBox_ciudad.Value
Cells(fila, 9).Value = form_clientes.TextBox_correo.Value
Cells(fila, 10).Value = form_clientes.TextBox_rut.Value
'categoria
Cells(fila, 7).Value = form_clientes.categoria.Value
Cells(fila, "K").Value = Now
'Codigo cliente
Dim cod As Integer
cod = WorksheetFunction.Max(Range("D:D")) + 1
Cells(fila, 4).Value = cod
'Notificar al usuario
MsgBox "Se ha ingresado el Cliente número:" & cod
End If
End Sub
Private Sub CommandButton2_Click()
End
End Sub
Private Sub UserForm_Initialize()
categoría.AddItem "1"
categoria.AddItem "2"
categoria.AddItem "3"
End SubEste es mi código y este es mi userform

3 Respuestas
Respuesta de No soy Perfecto
1
Respuesta de Dante Amor
2
Respuesta
1
