Ayuda con la macro algo le falta...

Hola buen día a todos mi pregunta es la siguiente: tengo un formulario creado por vb de excel lo que se supone que hace es ingresar registros a la hoja en curso y en caso de que el dato ya exista, emitir el mensaje de su existencia, mi problema es que al momento de validar la existencia si yo escribo en el textbox1 = jose martinez me deja ingresar el registro siendo que no debería por que ya existe pero como Jose Martinez, ojala me puedan ayudar a ver que me esta fallando ya que quiero que me avise si esta repetido incluso si cambia el formato de las letras en minúsculas o mayúsculas.
Dim R As Range
Usuario_repetido = textbox1.Text
Set R = [a:a].Find(What:=Usuario_repetido)
If txb1 = R Then
MsgBox "Nombre ya registrado!!" & UCase(txb1) & ".", vbExclamation
Else
Dim intRespuesta As Integer
intRespuesta = MsgBox("¿Es correcta la información?", vbQuestion + vbYesNo, "Información importante")
If intRespuesta = 6 Then
Rows("5:5").Select
Selection.insert Shift:=xlDown
ActiveCell = textbox1
ActiveCell.Offset(0, 1).Select
ActiveCell = textbox2
ActiveCell.Offset(0, 1).Select
ActiveCell = textbox3
ActiveCell.Offset(0, 1).Select
ActiveCell = textbox4
ActiveCell.Offset(0, 1).Select
ActiveCell = textbox5
ActiveCell.Offset(0, 1).Select
ActiveCell = textbox6
Range("A1:F65").Sort Key1:=Range("F2"), Order1:=xlAscending, Key2:=Range( _
"A2"), Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase _
:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, _
DataOption2:=xlSortNormal
MsgBox "Listo", vbInformation
textbox1 = Empty
textbox2 = Empty
textbox3 = Empty
textbox4 = Empty
textbox5 = Empty
textbox6 = Empty
Else
textbox1 = Empty
textbox2 = Empty
textbox3 = Empty
textbox4 = Empty
textbox5 = Empty
textbox6 = Empty
End If

1 Respuesta

Respuesta
1
Si lo que pasa es que la cadena : "jose martinez " y "Jose Martinez" son "cosas " distintas. Cambia esta linea
Set R = [a:a].Find(What:=Usuario_repetido)
por esto:
Set r = [a:a].Find(What:=Usuario_repetido, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=True, SearchFormat:=False).Activate
Si te sirve CIERRA la pregunta, si tienes otras preguntas habré "otra pregunta"
Antes que nada gracias por responder a mi auxilio y prosiguiendo a la respuesta, intente la sustitución del código pero me arroja un error el cual dice así: Variable de objeto o bloque with no establecido. Y si quito la sustitución del código que me indicaste funciona nuevamente pero como antes. Espero me puedas ayudar con ese error
Saludos
Prueba así
Set R = [a:a].Find(What:=Usuario_repetido, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=True, SearchFormat:=False)
Lo probé y esta ok
Hola muchas gracias nuevamente intente con tu código y me dio el mismo resultado del inicio pero bueno la solución que le di es que todo nombre la letra mayúscula sea inicial, saludos y muchas gracias..

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas